Say string[i] < 0 || string[i] > 9
.
Make sure you actually mean 0
(the value), and not '0'
(the character for the numeral for zero). In the latter case (as you suggest in the comment), you want string[i] < '0' || string[i] > '9'
. (The numerals are guaranteed to be contiguous and ordered in any text encoding, so this works on any platform.)