结构体所占字节
#include<stdio.h>#include<stdlib.h>
struct person
{
int id;
char name [12];
struct persom *next;
};
int main(void)
{
struct person *a;
a = (struct person *)malloc(sizeof(struct person));
printf("%d\n",sizeof(*a));
return 0;
}
得到的结果是:20
问题:结构体不是边界对齐吗?为何这个程序是直接各类型字节数相加的结果?