We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a147a57 + 98bc719 commit 2022e95Copy full SHA for 2022e95
008_atoi/atoi.c
@@ -26,9 +26,9 @@ static int myAtoi(char* str)
26
}
27
28
n = n * 10 + d;
29
- } else if (*s == '-' && isdigit(*(s + 1))) {
+ } else if (*s == '-' && isdigit(*(s + 1)) && (n == 0)) {
30
sign = 1;
31
- } else if (*s == '+' && isdigit(*(s + 1))) {
+ } else if (*s == '+' && isdigit(*(s + 1)) && (n == 0)) {
32
sign = 0;
33
} else {
34
break;
0 commit comments