下面是自我检测的区域,查看题目,自我回答,感觉自己掌握了就可以打勾

  • 查看结构体变量的偏移量的函数叫做什么
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>

/* 偏移=offset,off是远离,set是安置,远离安置点就是偏离 offsetof的用法 { 1:offsetof(struct 结构体名 , 结构体中的变量); 2:作用将结构体中的各个变量的字节数与空间位置返回给程序员! } NULL的用法 { NULL = (int*)0 = 0; NULL可以指代空指针,也能指代数字0; } */


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
=================================================