摘要:本文主要介绍C++11标准新出的string类型和数字类型的数据相互转换API
关键字:类型转换,string
1.头文件
头文件是:string
2.string转数字类型
- stoi()
1.说明:string 转 int
2.函数原型:
int stoi(const string& _Str, size_t *_Idx = 0, int _Base = 10)
- stol()
1.说明:string 转 long
2.函数原型:
long stol(const string& _Str, size_t *_Idx = 0, int _Base = 10)
- stoul()
1.说明:string 转 unsigned long
2.函数原型:
unsigned long stoul(const string& _Str, size_t *_Idx = 0, int _Base =
10)
- stoll()