Searching all the web for ways to serialize data in C so I could send a struct over a TCP/IP socket, I couldn't find anything simple. But I think that this way, you can fix the positions of the bits in a packet and thus serialize it "de facto".
packet *datapkt = NULL;
datapkt = (packet*)malloc(PKT_SIZE); // Allocation of memory with this size
datapkt->field = data;
......
send(datapkt);
free(datapkt);
Can anyone tell me if is this a good idea? This far it's working in my project.
Thanks in advance!