C++字符串转数字
#include <iostream>
#include <sstream>
using namespace std;
int stringToInt(string str)
{
int result;
istringstream is(str);
is >> result;
return result;
}
int main()
{
cout << stringToInt("Hello,world!") << endl;
cout << stringToInt("0000") << endl;
cout << stringToInt("0011") << endl;
cout << stringToInt("999999999999999999") << endl;
return 0;
}