码迷,mamicode.com
首页 > 其他好文 > 详细

string 类型转换

时间:2016-10-08 13:24:57      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

string转int

string str = "123";
int n = atoi(str.c_str());
cout << n << endl;

int转string

#include <sstream>
// int 转 string stringstream ss; int n = 123; string str; ss << n; ss >> str;

 

string 类型转换

标签:

原文地址:http://www.cnblogs.com/yuguangyuan/p/5938004.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!