设为首页 加入收藏

TOP

C++ - string类型转换int类型
2015-07-24 06:37:26 来源: 作者: 【 】 浏览:32
Tags:string 类型 转换 int

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



】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C++ - 同步读写文本 代码(C++) 下一篇HUNNU Contest 找数字2

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: