美文网首页
C标准库——

C标准库——

作者: Jack_6a46 | 来源:发表于2018-10-09 15:42 被阅读0次

    stddef.h 头文件定义了各种变量类型和宏。

    库变量

    ptrdiff_t 这是有符号整数类型,它是两个指针相减的结果。
    size_t 这是无符号整数类型,它是sizeof关键字的结果。
    wchar_t 这是一个宽字符常量大小的整数类型。

    库宏

    NULL 这个宏是一个空指针常量的值。

    offsetof(type, member-designator)会生成一个类型为size_t的整形常量,它是一个结构成员相对于结构开头的字节偏移量。成员是由menber-designator给定的,结构的名称是在type中给定的。

    typedef struct{
    char cName[10];
    char cGender;
    int num;
    }STJACK;
    void main()
    {
    printf("STJACK结构中的cName偏移量为 %d字节。\n", 
        offsetof(STJACK, cName));
    printf("STJACK结构中的num偏移量为 %d字节。\n",
        offsetof(STJACK, num));
    getchar();
    }
    
    image.png

    相关文章

      网友评论

          本文标题:C标准库——

          本文链接:https://www.haomeiwen.com/subject/znaeaftx.html