```
int myAtoi(char* str) {
int x=0;
int sign=1;
//skip blanks
while(*str==' ') str++;
if (strlen(str)==0) return 0;
//check sign
if(*str=='+' || *str=='-')
sign = *str++ == '+' ? 1 : -1;
while(*str <='9' && *str >='0'){
if(LONG_MAX/10 < x || (LONG_MAX/10 == x && LONG_MAX %10 < *str-'0'))
return sign == 1 ? LONG_MAX : LONG_MIN;
x = x*10 + *str++ -'0';
}
return sign*x;
}
```

This is bug report ~

- Input

"2147483648" - Output

-2147483648 - Expected

2147483647

Is is work fine in Code::Blocks 13