计算sizeof 对齐,该怎么解决
计算sizeof 对齐
------解决方案--------------------
union 是8
------解决方案--------------------
- C/C++ code
struct stu { union //联合体的sizeof 怎么计算? { char b[5]; int bh[2]; }class; char xm[8]; float cj; }xc; // sizeof(xc)是多少 ?
------解决方案--------------------
union 是8
------解决方案--------------------
- C/C++ code
struct stu { union //共用一段内存,按照最大的算,int一般占4字节,乘以二就是8 { char b[5]; int bh[2]; }class; char xm[8]; //char一般1字节,乘以8,就是8;8+8=16 float cj; //16+4=20 }xc; // sizeof(xc)是多少 ?
------解决方案--------------------