C++内存对齐问题。。。。出现了意想不到的结果
#include <stdio.h>
typedef union{
long i;
int k[5];
char c;
}DATE;
struct data
{
char c;
int cat;
DATE cow;
double dog;
}too2;
struct data1
{
char c;
int cat;
double dog;
}too;
void main(){
DATE max;
printf("%d\n",sizeof(max));
printf("%d\n",sizeof(too));
printf("%d\n",sizeof(too3));
printf("%d",sizeof(too2));
}
结果是:
20
16
32
40
难道too3 中的 char c占8个字节?????