Hi all,
I want to copy some struct to a char buffer (to send it over the network), so how can i deal with that (memcpy doesn't work for me), below a sample of my code:
Code:
struct proc_state {
long proc_id;
long proc_mem;
long proc_cpu;
};
int main(int argc, char *argv[]) {
struct proc_state *s;
outbuf = malloc(1024 * sizeof (char));
s = malloc(sizeof(struct proc_state ));
read_my_proc_state(s); /* I use this function to fill my structure*/
memcpy(outbuf, s, sizeof (s));
printf("The buffer to send is %s\n", outbuf);
return 0;
}
Thanks.