c

I can use more memory than how much I've allocated with malloc(), why?

char *cp = (char *) malloc(1); strcpy(cp, "123456789"); puts(cp); output is "123456789" on both gcc (Linux) and Visual C++ Express, does that mean when there is free memory, I can actually use more than what I've allocated with malloc()? and why malloc(0) doesn't cause runtime error? Thanks. ...

network topology

Hi, I'm trying to build an application that would display network topology, using c or maybe c++. I have knowledge of sockets. I know this a broad question with little details. It's just that i haven't found anything to start from. I have no idea what to do. ...

Emacs C++, opening corresponding header file

I am new to emacs and I was wondering if there is a shortcut to switch between header/source and the corresponding source/header file if there is a reference card like the general emacs ref card Thanks ! ...

shared buffer processes.

I am trying to call functions that are add some characters to the buffer and then remove them after. but am still failing to call the function properly. I am working on Linux. ERROR: q_add makes an integer without a cast. This is part of the code: do { printf("Enter shared buffer operation "); printf("i(init)/a(add)/r(remove...

Create read only folder in C language.

Hi, I am using C language and Linux OS as my programming platform. And I want to know how can I make a read-only folder programmatically? Is there any mkdir command in C language for Linux or Unix-like system? Thanks. ...

Why lsof shows odd sockets?

I am opening a unix domain socket on file system. lsof give me this as the output. proxyShel 27379 root 0u unix 0xe8250200 0t0 26605515 /var/lib/dsock proxyShel 27379 root 2u unix 0xe74e4600 0t0 26606355 socket Well, "dsock" is the socket I am listening to, but what does the second entry mean? :s ...

How can I return a pointer to an element inside an array of structs ?

What am I doing wrong here ? /* * Consider the following pseudo code ! */ typedef struct foobar { unsigned char id, count; struct foobar *child; } foobar; foobar root = (foobar *) malloc( sizeof(struct foobar) ); root->child = (foobar *) malloc( sizeof(struct foobar) ); root->count++; root->child[0].id = 1; root->count++; r...

[c] Why casting short to void * get a warning, and from int it's okey?

See I'm using glib, and gpointer is a typedef of void *. (glib did this type to make things clear, I guess). when I make a signal connect, I have to pass the data as void pointer (void *). so the code is (something like this) : ... g_signal_connect (object, function, (gpointer) data); ... If I use short as data type, I get a warning...

stack dump when copy characters to an array of char pointers

Hello, gcc 4.4.3 c89 I have the following source file. However, I get a stack dump on the following line: printf("dest: %d [ %s ]\n", i, dest[i]); The reason is that if fails to break from the for loop. I have tried different conditions in the for loop to try and break before printing. i != NULL i != '\0' i != 0 However, all of...

What are the free online certifcations available for Computer Science engineering students?

Hi friends, I would like to know about free online certifcations available for UG students in Computer Science engineering and can help in adding weight to the resume. I know there are many certifications from microsoft and Sun etc! But I cant afford them right now. Thnks in advance ...

How to copy text file in C or C++?

When trying to copy a text file A to another file B, there may have several methods: 1) byte by byte 2) word by word 3) line by line which one is more efficient? ...

Are there specific defines of linuxthreads and nptl

Hello I hav a programme, which must work differently for linuxthreads and nptl. Are there defines in this libs, that can be used in my programme to detect, is nptl is used or is linuxthreads is? UPDATE1: For runtime there is a getconf GLIBC_LIBPTHREADS, but what for compile-time? ...

Does this PyList_Append(list, Py_BuildValue(...)) leak?

Does this leak?: static PyObject* foo(PyObject* self, PyObject* args){ PyObect* list = PyList_New(0); for(int i = 0; i < 100; i++) // leak? does PyList_Append increment ref of the temporary? PyList_Append(list, Py_BuildValue("i", 42)); return list; } Though, I suppose it's better to do this, in any case?: ...

How to make a program that automatically synchronizes

Hey i am hoping to write a program where the program automatically just copy pastes all my dad's documents from D:\office folder. So whenever I plug-in my pen-drive , the program silently copies all documents inside my pen-drive. Also all files should be pasted to a hidden folder in the pen-drive (so it remains private) . Synchronizatio...

Time each CPU core spends in C0 power state

The title says it all. Any help figuring out how to do this would be great: How much time each CPU core spent in the C0 power state over the past second. This is for a mac app so Objective-C, cocoa and c are needed. Thank you! ...

Fastest JSON reader/writer for C++

I need C++ json parser & writer. Speed and reliability is very critical, I don't care if interface is nice or not, its Boost based or not, even C parser is also fine (if its considerably faster than C++ ones). If somebody has experience with speed of available JSON parsers, please advice. ...

File decriptors and socket connections..

I am trying to understand how are file descriptors related to sockets. As per my understanding, you listen on a particular file descriptor, once a connection comes in , you accept it , which returns you another file descriptor ( 2 in all ) and you use this 2nd descriptor to send/recv data. The strange behaviour i am observing is that a...

How to start an external program with a file from a C program when both paths have spaces?

I'm trying to fix an existing C-program with VS2005 that eventually calls int system(command) //in C:\Program Files\Microsoft Visual Studio 8\VC\crt\src\system.c) with parameter value start C:\Program Files\VideoLAN\VLC\vlc.exe C:\Documents and Settings\me\My Documents\My Music\09 - Track09.mp3 the program to be started and the ...

Copying some content of one array to another array without repetition of the contained data

Good day all, I have two array which I want to copy some data from the first array to the second array without repeating any values in the second array.Could someone tell me what I am not getting here. #include <stdio.h> #include <stdlib.h> #include <string.h> main() { char *hours; char *strl; hours={0,0,0,0,1...

Remote GDB debugging

I've just spent a whole day trying to find a way to enable gdb debugging from QtCreater or Eclipse. I learned that there are basically two approaches to launch the target application: using ssh (ssh host gdb) using gdbserver I was able to use both approaches to launch gdb remotely and start the application. However, GDB never reponds...