当前位置: C语言 -- 附录 -- rsize_t

rsize_t类型


描述:

该类型是一种无符号整数类型,等同于size_t类型,用以表示sizeof运算符的运算结果。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
/*类型rsize_t范例*/

#define __STDC_WANT_LIB_EXT1__ 1
#include <stdio.h>
#include <stdlib.h>

#define LENGTH 100

int main(void)
{
    /*获取计算机名。*/
    const char *str = "COMPUTERNAME";
    char computerName[LENGTH];
    rsize_t N = sizeof(computerName)/sizeof(char);
    size_t len;
    
    if(!getenv_s(&len, computerName, N, str))
        puts(computerName);

    return 0;
}


输出:

GCH-PC

注:使用Visual Studio编译。


相关内容:
size_t 表示sizeof运算符运算结果的无符号整数类型。