qfedu-c-level/day13/d3.c

15 lines
315 B
C
Raw Permalink Normal View History

#include <stdio.h>
#pragma pack(1) // 手动指定内存对齐,优点:可以减少内存的浪费,缺点:会降低内存的读取速度
struct
{
char a;
short b;
int c;
} p1;
int main()
{
printf("p1 size: %lu B\n", sizeof(p1));
printf("%p %p %p\n", &p1.a, &p1.b, &p1.c);
return 0;
}