size_t
定义于头文件
<stddef.h> |
||
定义于头文件
<stdio.h> |
||
定义于头文件
<stdlib.h> |
||
定义于头文件
<string.h> |
||
定义于头文件
<time.h> |
||
定义于头文件
<uchar.h> |
(C11 起)
|
|
定义于头文件
<wchar.h> |
(C95 起)
|
|
typedef /*implementation-defined*/ size_t;
|
||
size_t
是 sizeof 、 _Alignof (C11 起) 和 offsetof 的结果的无符号整数类型,定义取决于数据模型。
|
(C99 起) |
注解
size_t
能存储理论上可行的任何类型(包括数组)对象的最大大小。
size_t
通常用于数组下标和循环计数。将如 unsigned int 的其他类型用作数组下标的的程序,可能在 64 位系统上失败,例如在下标超过 UINT_MAX 时,或若依赖 32 位模算术。
示例
可能的输出:
SIZE_MAX = 18446744073709551615 size = 400
引用
- C11 标准(ISO/IEC 9899:2011):
-
- 7.19 Common definitions <stddef.h> (p: 288)
-
- 7.20.3 Limits of other integer types (p: 293)