C语言计算结构体偏移量

#include <stido.h>
#include <stdlib.h>
#include <stddef.h>
struct Person
{
    char a;  // 0 --- 3
    int  b; //4---7
    char buff[100];  // 8 -- - 107
        int d; //108 -- 111
};
void main()
{
    printf("p.d的偏移量%d", offsetof(struct Person, d));
    system("pause");

}

 

 

posted @ 2018-07-25 09:00  LifeOverflow  阅读(697)  评论(0)    收藏  举报