#define offsetof(s, m) (size_t)&(((s *)0)->m) |
#include <stdio.h>
struct demo {
char c;
int i;
int k;
char u;
char name[10];
};
int main()
{
size_t pos;
pos = (size_t)&(((struct demo *)0)->k);
printf("%d\n",pos);
return 0;
}
beyes@linux-beyes:~/C/base> ./offsetof.exe
8
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |