typedef union {
Long L;
int i[5] ;
char c;
} UNION;
typedef struct {
int like;
UNION coin;
double collect;
} STRUCT ;
int main(void) {
printf("sizeof (UNION)三%zu\n",sizeof(UNION) );
printf("sizeof(STRUCT) = %zu\n", sizeof(STRUCT)) ;}
这个struct不应该输出16吗,为什么是32
因为struct中有double类型,因此会是8字节对齐。union中最长的是int i[5],加上前面的int like,正好6个int,即24字节。所以加上8就是32字节