相同点
都是c的文字处理函数,将数字字符串转换为int输出
头文件均为#includecstring
不同点
由于atoi (的参数为constchar ),因此必须对字符串str调用c_str )的方法将此string转换为const char*类型,但stoi )的参数为const string*
stoi ) )进行范围检查。 默认范围在int范围内,如果在范围外,则为runtimeerror!
另一方面,atoi ()不进行范围检查。 如果在范围外,超过上界则输出上界,超过下界则输出下界