这是一个C语言已有的库函数。在 <stddef.h>中。它的作用是计算成员变量在结构体中的偏移量。
FEP:
#include <stddef.h>
#include <stdio.h>
struct address {
char name[50];
char street[50];
int phone;
};
int main()
{
printf("address 结构中的 name 偏移 = %d 字节。\n",
offsetoff_bak(struct address, name));
printf("address 结构中的 street 偏移 = %d 字节。\n",
offsetoff_bak(struct address, street));