可能重複:
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