Possible Duplicates:
How to convert struct to char array in C
Portable way of writing a C struct to a file (Serialisation for C)
我正在寻找将结构转换为C语言中的字节数组的方法,对此我感到困惑。请向我展示实现该目标的正确方法。提前致谢。
Possible Duplicates:
How to convert struct to char array in C
Portable way of writing a C struct to a file (Serialisation for C)
我正在寻找将结构转换为C语言中的字节数组的方法,对此我感到困惑。请向我展示实现该目标的正确方法。提前致谢。
最佳答案
结构是字节数组。它以&mystruct
开头,长度为sizeof(mystruct_type)
个字节。
如果二进制文件太长或包含空格,请检查#pragma pack
设置。
hth
马罗
关于c - 如何在C中将结构转换为字节数组? ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5959390/