函数如下:
Functions
Convert from strings
-
stoi
- Convert string to integer (function template )
-
stol
- Convert string to long int (function template )
-
stoul
- Convert string to unsigned integer (function template )
-
stoll
- Convert string to long long (function template )
-
stoull
- Convert string to unsigned long long (function template )
-
stof
- Convert string to float (function template )
-
stod
- Convert string to double (function template )
-
stold
-
Convert string to long double
(function template )
Return Value
On success, the function returns the converted integral number as an int value.Example
| |
|
Output:
2001, A Space Odyssey: 2001 and [, A Space Odyssey] 40c3: 16579 -10010110001: -1201 0x7f: 127 |
注意所在头文件为 <string>。
提供函数调用,字符串不仅可以转成十进制整数,还可以转成其他基数的整数。