I\'m trying to read unknown number of integers by this piece of code:
while (1) {
int c = getchar ();
if (c == EOF)
break;
el
C specifies the 10 decimal digits, not surprisingly, as
0 1 2 3 4 5 6 7 8 9
C11 §5.2.1 further states "In both the source and execution basic character sets, the value of each character after 0 in the above list of decimal digits shall be one greater than the value of the previous.
Thus when assessing a string for characters that are digits, the language guarantees that subtracting '0'
from a decimal digit char
will result in its integer value.
if (isdigit (c))
int value = c - '0';
This is not dependent on char
using ASCII.