小编Joa*_*ira的帖子

如何在没有填充位的情况下在C中输出二进制文件

我想将结构数据输出到二进制文件,但每个变量的信息之间没有任何填充位.例如:

struct s {
    int i1;
    short s1;
    char c1;
};
struct s example[2];
Run Code Online (Sandbox Code Playgroud)

如果我使用fwrite(&example, sizeof(struct s), 2, file)的二进制文件仍然之间,例如,填充比特s1c1,也从c1i1 (of the 2nd struct).

从输出文件中删除这些填充位的好方法是什么?

谢谢!任何帮助表示赞赏

c binary bits padding output

3
推荐指数
1
解决办法
1045
查看次数

标签 统计

binary ×1

bits ×1

c ×1

output ×1

padding ×1