c sizeof的问题
typedef struct
{
unsigned name:8;//名称
unsigned type:8;//数据类型
unsigned data:8;//数据
}DataModeA;
typedef struct
{
unsigned name:8;
unsigned type:8;
unsigned data:16;
}DataModeB;
typedef struct
{
unsigned name:8;
unsigned type:8;
unsigned data:32;
}DataModeC;
sizeof计算结果
sizeof(DataModeA) = 4;
sizeof(DataModeB) = 4;
sizeof(DataModeC) = 8;
什么问题啊?
[解决办法]
lz的疑惑在哪?
这是内存对齐,google之。