that works. Thanks. I thought atoi would be needed after storing it in the char *.
Type: Posts; User: hashbang
that works. Thanks. I thought atoi would be needed after storing it in the char *.
you might be right as it does not seem too work.
ah...
memcpy(&a,foo,4);
Yes it does, but I am not sure what I am missing.
So using malloc should work? The actuall pinter is malloc'd memory.
int a,b;
char *foo = malloc(sizeof(char) * 100);
int num = 123456;
memcpy(foo,&num,4);
...
Hi,
I'm trying to add a int to the first four bytes of a char * and then later on I have to extract the int from the char *.
Example
char *foo = " number";
int num = 123456;...