如何得到一个field在结构体(struct)中的偏移量?
如何得到一个field在结构体(struct)中的偏移量?
日期:2021-07-20 04:24:59 人气:1
使用offsetof宏
#include <stddef.h>
#include <stdio.h>
struct People {
unsigned int age;
char gender;
int income;
};
int main(void)
{
printf("%d\n%d\n%d\n",
#include <stddef.h>
#include <stdio.h>
struct People {
unsigned int age;
char gender;
int income;
};
int main(void)
{
printf("%d\n%d\n%d\n",