结构体定义
1. 先声明再定义
struct student {
int a;
};
struct student t1;
2. 声明定义一起
struct student {
int a;
} t1;
3. 定义结构体类型
typedef struct student {
int a = 0;
} STUDENT;
STUDENT t1;
结构体大小计算
1. 空结构体大小为1
typedef struct {
} T;
2. 不同顺序
typedef struct {
int a = 0;
char b = 0;
} T1;
typedef struct {
char b = 0;
int a = 0;
} T2;
printf("%d %d %d\n", sizeof(T), sizeof(T1), sizeof(T2));