std::stoul, std::stoull
来自cppreference.com
< cpp | string | basic string
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <string> 中定义
|
||
unsigned long stoul( const std::string& str, size_t *pos = 0, int base = 10 ); |
(1) | (C++11 起) |
unsigned long long stoull( const std::string& str, size_t *pos = 0, int base = 10 ); |
(2) | (C++11 起) |
解释一个无符号整数的值的字符串
str
.原文:
Interprets an unsigned integer value in the string
str
.Function discards any whitespace characters until first non-whitespace character is found. Then it takes as many characters as possible to form a valid base-n (where n=base) unsigned integer number representation and converts them to an integer value. The valid unsigned integer value consists of the following parts: None
- (可选) prefix (
0
) indicating octal base (applies only when the base is 8) - (可选) prefix (
0x
or0X
) indicating hexadecimal base (applies only when the base is 16) - a sequence of digits
The set of valid digits for base-2 integer is 01
, for base-3 integer is 012
, and so on. For bases larger than 10
, valid digits include alphabetic characters, starting from Aa
for base-11 integer, to Zz
for base-36 integer. The case of the characters is ignored.
的第一个未转化的字符的索引被存储在
pos
。 NULL通过为pos
,被忽视原文:
The index of the first unconverted character is stored in
pos
. If NULL is passed as pos
, it is ignored.目录 |
[编辑] 参数
str | - | 要转换的字符串。一个整数来存储索引的第一个未转换的字符
|
pos | - | 原文: address of an integer to store the index of the first unconverted character |
base | - | 地址。基数
|
[编辑] 返回值
的字符串转换为指定的无符号整数类型
原文:
The string converted to the specified unsigned integer type.
[编辑] 例外
- std::invalid_argument如果没有可以进行转换原文:std::invalid_argument if no conversion could be performed
- std::out_of_range如果转换后的值会掉出来的结果类型的范围.原文:std::out_of_range if the converted value would fall out of the range of the result type.
[编辑] 另请参阅
(C++11) (C++11) (C++11) |
将字符串转换为一个有符号整数 原文: converts a string to an signed integer (函数) |
(C++11) (C++11) (C++11) |
将字符串转换为浮点值 原文: converts a string to an floating point value (函数) |