1 字符串 转 数字
方法一:
string a = "12345";
int b;
stringstream ss;
ss << a;
ss >> b;
cout << b;
方法二:
string a = "12345";
int b=stoi(a);//stoi() 包含在 #include <string> 中
cout << b;
2 数字 转 字符串
方法一:
string a;
int b=12345;
stringstream ss;
ss << b;
ss >> a;
cout << a;
方法二(C++11):
string a;
int b=12345;
a = to_string(b);
cout << a;