📜  libc++abi.dylib:以 std::invalid_argument 类型的未捕获异常终止:stoi:无转换 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:45.989000             🧑  作者: Mango

代码示例1
#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<