英文原文:http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.11.html
原文作者:Eric Huss
中文译者:柳惊鸿 Poechant
版权声明:本文的原文版权归Eric Huss所有,中文译文版权归Poechant所有。转载请注明来自"柳大的CSDN博客":http://blog.csdn.net/poechant
11. stddef.h
头文件stddef提供了一些标准定义。其中很多定义也会出现在其他头文件中。
宏:
NULL
offsetof();
类型:
typedef ptrdiff_t
typedef size_t
typedef wchar_t
11.1. 变量和定义
ptrdiff_t是相减两个指针的结果。
size_t是无符号整型。
wchar_t是一个具有宽字符常量大小的整型.
NULL是空指针常量值。
offsetof(type, member-designator)
他会产生一个size_t类型的整型常量结果,它是结构的开始处的成员的偏移量(字节为单位)。member-designator指定成员,type指定结构名。
实例:
#include<stddef.h>
#include<stdio.h>
int main(void)
{
struct user{
char name[50];
char alias[50];
int level;
};
printf("level is the %d byte in the user structure.\n"),
offsetof(struct user,level));
}
输出结果:
level is the 100 byte in the user structure.
该系列译文在持续更新中⋯⋯
C标准库参考指南系列译文(1)assert.h
C标准库参考指南系列译文(2)ctype.h
C标准库参考指南系列译文(3)errno.h
C标准库参考指南系列译文(4)float.h
C标准库参考指南系列译文(5)limits.h
C标准库参考指南系列译文(6)locale.h
C标准库参考指南系列译文(7)math.h
C标准库参考指南系列译文(8)setjmp.h
C标准库参考指南系列译文(9)signal.h
C标准库参考指南系列译文(10)stdarg.h
C标准库参考指南系列译文(11)stddef.h
C标准库参考指南系列译文(12)stdio.h(A)
版权声明:本文的原文版权归Eric Huss所有,中文译文版权归Poechant所有。转载请注明来自"柳大的CSDN博客":http://blog.csdn.net/poechant
-