Putting 0 at the beginning of the number tells the compiler that the value is expressed in octal; octal numbers are from 0 to 7, so "789" is not a valid octal number. The only solution here is to remove 0 from the beginning of the number (assuming you meant that the number should be decimal) .... or provide a real octal number (if you really wanted to use octal).
Well, I suppose you could do this:
int temp = atoi("0789");
But this will be quite inefficient, as the value will be computed from the string at run time, and not compiled directly.
source share