#include <stdio.h>
struct A {
short s;
int i;
long l;
float f;
char c;
double d;
};
int main ()
{
printf("%d\n", sizeof(char));
printf("%d\n", sizeof(short));
printf("%d\n", sizeof(int));
printf("%d\n", sizeof(long));
printf("%d\n", sizeof(float));
printf("%d\n", sizeof(double));
printf("%d\n", sizeof(struct A));
return 0;
}
你是在64位系统下的
输出依次为:
1
2
4
8
4
8
1补全为4,2补全为4 所以 4 + 4 + 4 + 8 + 4 + 8 = 32
你的电脑上前面那些加起来不等于A的字节数?