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;
原文地址:https://www.cnblogs.com/yuguangyuan/p/5938004.html