C语言计算结构体偏移量
#include <stido.h> #include <stdlib.h> #include <stddef.h> struct Person { char a; // 0 --- 3 int b; //4---7 char buff[100]; // 8 -- - 107 int d; //108 -- 111 }; void main() { printf("p.d的偏移量%d", offsetof(struct Person, d)); system("pause"); }
为什么要奋斗?因为我有梦想!为了诗和远方!

浙公网安备 33010602011771号