#include "stdafx.h"
#include<iostream>
using namespace std;
struct A
{
int a;
int b;
int c;
};
struct B
{
};
struct C
{
char a;
int i;
} ;
struct D
{
int i;
char a;
};
struct E
{
char a;
};
int _tmain(int argc, _TCHAR* argv[])
{
cout<<sizeof(A)<<endl;
cout<<sizeof(B)<<endl;
cout<<sizeof(C)<<endl;
cout<<sizeof(D)<<endl;
cout<<sizeof(E)<<endl;
getchar();
return 0;
}
运行结果是 12
1
8
8
1
A好理解,3个int,每个4个字节,正好12个