#include <stdio.h >
void main(){
struct t1{
int a;
char b;
float c;
union uu{
char u1[5];
int u2[2];
}ua;
}myaa ;
printf("%dn",sizeof(myaa));
为啥结果不是17是20,求大神解答
#include <stdio.h >
void main(){
struct t1{
int a;
char b;
float c;
union uu{
char u1[5];
int u2[2];
}ua;
}myaa ;
printf("%dn",sizeof(myaa));
为啥结果不是17是20,求大神解答
因为结构体的内存对齐了,这样能加速内存访问。
关于内存对齐的内容,你可以搜索 关键字:c 内存对齐