求解一个结构体大小疑点
求解一个结构体大小问题C/C++ code typedef struct{char ashort bchar c}MY_TEST_ST1以上的结构,在默
求解一个结构体大小问题
C/C++ code typedef struct{ char a; short b; char c;}MY_TEST_ST1;
以上的结构,在默认的4字节对齐的情况下,大小为什么是6个字节?
哪位朋友给出详细解释?
[解决办法]typedef struct
{
char a; //1
//1
short b; //2
char c; //1
//1
}MY_TEST_ST1;
6字节.
除了内部对齐, 结构体整个对齐到min(sizeof(short), 4)
[解决办法]