初中生
最后登录1970-1-1
在线时间 小时
注册时间2014-4-5
|
发表于 2014-4-5 13:24:42
|
显示全部楼层
应该是 6+2 + 8 + 4 =20
#include <stdio.h>
struct stu
{
union{ //6
char bj[5];
int bh[2];
}class;
char xm[8]; //8
float cj; //4
}test;
int main()
{
printf("bj_address = %d\n",(long)(&test.class.bj) );
printf("bh_address = %d\n",(long)(&test.class.bh) );
printf("xm_address = %d\n",(long)(&test.xm) );
printf("cj_address = %d\n",(long)(&test.cj) );
printf("test size = %d\n",sizeof(test));
getchar();
return 0;
}
bj_address = 4210784
bh_address = 4210784
xm_address = 4210792
cj_address = 4210800
test size = 20
|
|