可能重复:
Why isn't sizeof for a struct equal to the sum of sizeof of each member?为什么struct的sizeof与其成员之和不同?
如果我实现下面的代码,我的sizeof的输出(*拉链)是56。 [10 + 10 + 4 + 4 * 8]字节= 56
typedef struct{
char a[10];
char b[10];
int c;
double d,f,g,h;
}abc_test;
abc_test zip[] =
{
{"Name" ,"Gender", 0,100,200,300,400},
{"Name" ,"Gender", 0,100,200,300,400}
};
但是,当我实现下面的代码,我的sizeof的输出(*拉链)是440 [100 + 100 + 100 + 100 + 4 + 4 * 8] = 436,我的问题是另一个4在哪里?
typedef struct{
char a[100];
char b[100];
char i[100];
char j[100];
int c;
double d,f,g,h;
}abc_test;
abc_test zip[] =
{
{"Name" ,"Gender","age","mode", 0,100,200,300,400},
{"Name" ,"Gender","age","mode", 0,100,200,300,400}
};
哪个编译器和操作系统? –
Microsoft Visual Studio 2005(嵌入在鹰测试系统中) – bamboolouie