你可能不知道的編程小問題:預處理、sizeof

面試題9、用一個定義宏FIND求一個結構體stuct裏某個變量相對stuct的偏移量。 struct aa { int a; char b[20]; }; 答案--#define FIND(struct,e) (size_t)&(((struct*)0)->e)。FIND(aa,a);//等於0;FIND(aa,b);//等於4面試 解析--(struct *) 0表示把一段地址(以0開頭的地
相關文章
相關標籤/搜索