在使用C++内置的字符串转整形函数stoi()时,我们可能遇到如下报错:
terminate called after throwing an instance of 'std::invalid_argument' what(): stoi
这是因为我们在参数中传入了不可转化为整形的字符串,比如stoi("abc");
这显然是不行的,应当检查程序,进行输入类型检查。
希望我的分享能帮到你~~~
在使用C++内置的字符串转整形函数stoi()时,我们可能遇到如下报错:
terminate called after throwing an instance of 'std::invalid_argument' what(): stoi
这是因为我们在参数中传入了不可转化为整形的字符串,比如stoi("abc");
这显然是不行的,应当检查程序,进行输入类型检查。
希望我的分享能帮到你~~~