字符串变为整数的问题
差不多两年没弄C++了,现在回头看看发现好多东西怎么这么不方便呢。
标准库里提供了atoi这样子的函数来完成字符串转换到整数的功能。
但是Each function returns the int value produced by interpreting the input characters as a number. The return value is 0 for atoi and _wtoi, if the input cannot be converted to a value of that type.
MSDN上这么说,也就是说如果输入的字符串有问题,无法转换,则返回0。
那么我怎么知道到底转换成功没有?真的原始字符串就是"0"还是说输入的字符串有问题。
有没有别的函数可以做这个转换工作?限定在C++标准库和MFC的范围以内。