This article speaks very well: http://blog.csdn.net/hairetz/article/details/4084088
Use space to change time,
Rule : The starting position of each data member store is the integer number of its integer or its child member, and the structure's whole length is an integer multiple of its internal maximum member, which is not sufficient.
#include <stdio.h>typedefstructa{intId//[0] ... [3] DoubleHeight//[8] ... [A] Charname[Ten];//[20] ... []//The overall length must be an integer multiple of 8, otherwise automatically padded, so the length is 32, in accordance with the integer multiples of 8}a;typedefstructb{intNo//[0] ... [3]A b;//[8] ... [Max] A has a maximum of 8 members, not 10. So start with an integer multiples of 8. The total length is 40, which conforms to the integer multiples of 8}b;intMain () {printf ("%d%d\n",sizeof(A),sizeof(B)); Exit (0);}
You can use your own alignment using #pragma pack (n).
The #pragma pack (1) masks out the memory alignment.
C-Language memory alignment pairs