试一试:
typedef struct
{
int a;
char b;
short c;
}A;
typedef struct
{
char a;
int c;
short b;
}B;
#pragma pack(1)
typedef struct
{
int a;
char b;
short c;
}C;
#pragma pack()
typedef struct
{
char a;
int c;
short b;
}D;
int main()
{
printf("The size of A is %d./n", sizeof(A));
printf("The size of B is %d./n", sizeof(B));
printf("The size of C is %d./n", sizeof(C));
printf("The size of D is %d./n", sizeof(D));
return 0;
}
结构体大小与内存对齐
1484

被折叠的 条评论
为什么被折叠?



