1.基本理解
  比如:struct TEST
  {
  char a;
  int b;
  char c;
  }
  那么经过sizeof后得出结果是 12, 因为默认内存占用4byte, 变量a占用1byte,剩下3个,不足以存放变量b,故变量a也占用了4byte, 变量c由于后面没有了数据, 也会变为4byte,后sizeof值为12。
#include "stdafx.h"
#include <iostream>
using namespace std;
struct TEST1    //12
{
char a;
int b;
char c;
};
struct TEST2    //8
{
char a;
char b;
int c;
};
struct TEST3    //8
{
char a;
char b;
char c;
int d;
};
struct TEST4    //12
{
char a[5];
int b;
};
struct TEST5    //8 + 8 + 8 = 24
{
double a; //8
char b; //4
int c; //4,location the b memery
char d[5]; //5
};
int _tmain(int argc, _TCHAR* argv[])
{
struct TEST1 t1;
struct TEST2 t2;
struct TEST3 t3;
struct TEST4 t4;
struct TEST5 t5;
cout << sizeof(t1) << endl << sizeof(t2) << endl;
cout << sizeof(t3) << endl << sizeof(t4) << endl << sizeof(t5) << endl;
return 0;
}