下面是自我检测的区域,查看题目,自我回答,感觉自己掌握了就可以打勾
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
void STDDEF_TEXT()
{
struct MyStruct
{
char Name[5];
unsigned int Age;
char Six;
};
printf("MyStruct结构体Name偏移量:%d\n",offsetof(struct MyStruct,Name));
printf("MyStruct结构体Age偏移量:%d\n",offsetof(struct MyStruct,Age));
printf("MyStruct结构体Six偏移量:%d\n",offsetof(struct MyStruct,Six));
}
=================================================
运行结果:
topeet@ubuntu:~/Desktop$ ./a.out
MyStruct结构体Name偏移量:0
MyStruct结构体Age偏移量:8
MyStruct结构体Six偏移量:12
=================================================