您的位置:首页 > 编程语言 > C语言/C++

C++ - string类型转换int类型

2014-06-08 20:16 330 查看

string类型转换int类型

本文地址: http://blog.csdn.net/caroline_wendy

C语言转换形式:
...
std::string str;
int i = atoi(str.c_str());
...

C++转换形式(C++11):
...
std::string str;
int i = std::stoi(str);
...
同样, 可以使用 stol(long), stof(float), stod(double) 等.

参考: http://en.cppreference.com/w/cpp/string/basic_string/stol
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Mystra C++ string 转换 int