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.
...
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.
...
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 !
...
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...
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.
...
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
...
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...
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...
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...
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
...
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?
...
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 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?:
...
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...
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!
...
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.
...
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...
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 ...
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...
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...