📅  最后修改于: 2022-03-11 14:44:45.989000             🧑  作者: Mango
#include
#include
// remove empty spaces in string you want to convert
string dirtystring = " 13 ";
std::string cleanstr = dirtystring;
cleanstr.erase(remove(cleanstr.begin(), cleanstr.end(), ' '), cleanstr.end());
dirtystring = str2;
// Proceed to converting it to an int using stoi
// Convert string to int
int n;
stringstream ( strr ) >> n;
cout << n; //Output:13
// Check the type requires #include
cout<