字节对齐的问题

#include <iostream>
using namespace std;
typedef struct _A
{
 char c;
 int i;
} A;

typedef struct _B
{
 A a;
 double d;
} B;

typedef struct _C
{
 A a;
 char c;
} C;
int main(void)
{
 cout << sizeof(A) << endl;
 cout << sizeof(B) << endl;
 cout << sizeof(C) << endl;
 return 0;
}

 8

16

12

posted @ 2012-06-28 11:22  byfei  阅读(108)  评论(0编辑  收藏  举报