结构体中成员变量偏移量

来源:互联网 发布:破解软件的app 编辑:程序博客网 时间:2024/05/02 04:57
#include <stdio.h>

struct student
{
int a;
int d;
int b;
int c;
};
  
int main()     
{   

printf("%d\n", &(((struct student *)0)->b));

printf("%d\n", ((unsigned int)(p) - ((unsigned int)&(p->b)))

return 0;   

}

显示结果:

8
-8
Press any key to continue

原创粉丝点击