Serialization of struct
Following example shows a simplest way to serialize struct into char array and de-serialize it. #include <iostream> #include <cstring> #define BUFSIZE 512 #define PACKETSIZE sizeof(MSG) using namespace std; typedef struct MSG { int type; int priority; int sender; char message[BUFSIZE]; }MSG; void serialize(MSG* msgPacket, char *data); void deserialize(char *data, MSG* msgPacket); void printMsg(MSG* msgPacket); int … Read more