字节对齐的问题

#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

原文地址:https://www.cnblogs.com/byfei/p/3112391.html