请问标准类库中的size_t是多大?

budbreak 2003-03-11 02:28:47
rt
...全文
93 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
budbreak 2003-03-13
  • 打赏
  • 举报
回复
3x
ttzzgg_80713 2003-03-11
  • 打赏
  • 举报
回复
2个字
bugfree 2003-03-11
  • 打赏
  • 举报
回复
4个字节
在stdio.h 中
typedef unsigned int size_t;
budbreak 2003-03-11
  • 打赏
  • 举报
回复
我的数组好像太大了
zhouzhaohan 2003-03-11
  • 打赏
  • 举报
回复
In C99 C 语言标准中:
6.5.3.4 The sizeof operator
Constraints
1 The sizeof operator shall not be applied to an expression that has function type or an
incomplete type, to the parenthesized name of such a type, or to an expression that
designates a bit-field member.
Semantics
2 The sizeof operator yields the size (in bytes) of its operand, which may be an
expression or the parenthesized name of a type. The size is determined from the type of
the operand. The result is an integer. If the type of the operand is a variable length array
type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an
integer constant.
3 When applied to an operand that has type char, unsigned char, or signed char,
(or a qualified version thereof) the result is 1. When applied to an operand that has array
type, the result is the total number of bytes in the array.84) When applied to an operand
that has structure or union type, the result is the total number of bytes in such an object,
including internal and trailing padding.
******4 The value of the result is implementation-defined, and its type (an unsigned integer type)

7.17 Common definitions <stddef.h>
1 The following types and macros are defined in the standard header <stddef.h>. Some
are also defined in other headers, as noted in their respective subclauses.
2 The types are
ptrdiff_t
which is the signed integer type of the result of subtracting two pointers;
size_t
which is the unsigned integer type of the result of the sizeof operator; and
wchar_t

综上,是unsigned int
is size_t, defined in <stddef.h> (and other headers).
budbreak 2003-03-11
  • 打赏
  • 举报
回复
那么用vector<T> vec(n)
n 多大才会超出呢?
谢谢
pengzhenwanli 2003-03-11
  • 打赏
  • 举报
回复
DWORD

69,337

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧