代码编辑说明文档
作者:互联网
1 代码偏移指令offsetof
#include <stddef.h> #include <stdio.h> struct address { int aa; int bbb; int name[50]; char street[50]; int phone; }; int main() { printf("address 结构中的 name 偏移 = %ld 字节\n",offsetof(struct address, name)); printf("address 结构中的 street 偏移 = %ld 字节\n",offsetof(struct address, street)); printf("address 结构中的 phone 偏移 = %ld 字节\n",offsetof(struct address, bbb)); return(0); }
标签:struct,int,代码,编辑,street,文档,address,偏移,offsetof 来源: https://www.cnblogs.com/baolixin/p/14913579.html