x86-64 架构下结构体大小计算示例及解析
#include <stdio.h>
struct P1 { int i; char c; int j; char d; };
struct P2 { int i; char c; char d; long l; };
struct P3 { int i; char c; short s; int j; };
int main() { struct P1 p1; struct P2 p2; struct P3 p3; printf('%ld %ld %ld ', sizeof(p1), sizeof(p2), sizeof(p3)); return 0; }
输出结果应为: 16 16 12
原文地址: https://www.cveoy.top/t/topic/paPl 著作权归作者所有。请勿转载和采集!