关于C语言中的结构体所占的字节数 sizeof(struct)
C语言中的结构体所占的字节数 ,用sizeof求一个结构体的大小
C语言中用sizeof求结构体所占字节数的详细方法。
一、非嵌套结构体
struct one{
char a; // 1(char所占字节数) + 0(偏移量)
short b; // 2(short所占字节数) + 2(偏移量)
int c; // 4(int所占字节数) + 4(偏移量)
};
struct two{
char a; // 1 + 0
原创
2022-05-03 23:25:16 ·
4446 阅读 ·
0 评论