错误地方如下:
在
- //********************************************************************之间的代码。原因是:
- ? 如果最后一个字符不是'\0'结尾,你就不能使用strlen
- 下面代码
- if (maxLimiterror1:这段括号中的代码根本不会执行,因为如果sum * 10溢出了,那么此时你比较的就是溢出后的值。error2: 这段代码执行后应该立即跳出循环,但是你写的并不会直接跳出,还要执行后面的语句3.可能正确的代码int _strToInt2(const char * str) {
- const int maxLimit = ((unsigned int) 0 - 1) >> 1;
- const int minLimit = maxLimit + 1;
- if (str == NULL || *str == '\0') {
- cout << "The string is empty or empty" <
来源: http://www.92to.com/bangong/2017/04-10/20246384.html