-5
#include <stdio.h>
struct temp{
char b1;
double a;
int f;
};
int main()
{
struct temp temp1;
int size = 0;
size = sizeof(temp1);
}
为什么size值是24而不是20?...在32位机器中。C编程结构
先谢谢了...
#include <stdio.h>
struct temp{
char b1;
double a;
int f;
};
int main()
{
struct temp temp1;
int size = 0;
size = sizeof(temp1);
}
为什么size值是24而不是20?...在32位机器中。C编程结构
先谢谢了...
struct temp{
char b1; // 1 byte + 7 bytes padding
double a; // 8 bytes
int f; // 4 bytes + 4 bytes padding
};
这是因为成员的填充:)
因为成员对齐的。 –
您是否在发布您的问题之前进行搜索?这个问题充满了重复。 – Stargateur
Google结构填充。 –