摘要: 最近看了面试宝典的一个题,写一个宏函数FIND(struc,a),要算出结构体里的变量相对于结构体的偏移量,如:1 typedef struct{2 int a;3 char b;4 int ccc;5 }b;6 FIND(b,a)//结果为0我并没有采用书上的方法,我自己试了一下,程序如下:#define FIND(struc,a) { printf("%p\n",(&(struc.a)) - (&struc)); }typedef struct{ int a; char b; int ccc;}b;void main(){ int d; ... 阅读全文
posted @ 2012-10-22 12:15 曾经的你| 阅读(445) 评论(2) 推荐(0) 编辑