Possible duplicates:How to convert a struct to a char array in CA portable way to write a C structure to a file (Serialization for C)
I'm looking to convert a structure to an array of bytes in C, and I was confused about this. Please show me the right way to achieve this. Thanks in advance.
The structure is an array of bytes. it starts with &mystructand has a length of sizeof(mystruct_type)bytes.
&mystruct
sizeof(mystruct_type)
If the binaries are long or contain spaces, check the settings #pragma pack.
#pragma pack
Hth
Maro