二十五岁时我们都一样愚蠢、多愁善感,喜欢故弄玄虚,可如果不那样的话,五十岁时也就不会如此明智。
标题:C库宏 offsetof()
C库宏 offsetof()
#include <stddef.h> #include <stdio.h> struct address { char name[50]; char street[50]; int phone; }; int main () { printf("name offset = %d byte in address structure.\n", offsetof(struct address, name)); printf("street offset = %d byte in address structure.\n", offsetof(struct address, street)); printf("phone offset = %d byte in address structure.\n", offsetof(struct address, phone)); return(0); }