c++中将string类型转换成int,该怎么处理

c++中将string类型转换成int如果有一个string类型的数据如“123”怎么转换成int类型的也就是123[解决办法]st

c++中将string类型转换成int
如果有一个string类型的数据如“123”怎么转换成int类型的也就是123
[解决办法]

    string s = "123";
    int n = stoi(s );

[解决办法]
#include <sstream>
#include <string>
using namespace std;

string s = "123";
stringstream ss(s);
int value;
ss >> value;

[解决办法]
引用:
string str="123";
int i;
i = atoi(&amp;str[0]);
这个方法最好