首页 > 技术文章 > string 类型转换

yuguangyuan 2016-10-08 11:45 原文

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;

 

推荐阅读