#include <stdio.h>
#pragma pack(push) //保存对齐状态
#pragma pack(2)
typedef struct{
char s[10];
int a;
}MYTYPE;
#pragma pack(pop)
typedef struct node
{
int a[100];
char b;
}kkk;
MYTYPE x;
void main()
{
kkk ka;
printf("size in byte of the structure %d \n", sizeof x);
printf("size in byte of the structure %d \n", sizeof ka);
}
为什么要关心结构体大小呢?