string 类型转换

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;

 

posted @ 2016-10-08 11:45  于光远  阅读(264)  评论(0编辑  收藏  举报