For the 10 numeric digit characters the C standard requires them to be in sequence:
5.2.1 Character sets
3 ... 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.
Other characters, such as alphabet letters, are not required to be in sequence. The uppercase and lowercase ASCII character alphabet characters are in sequence, but the EBCDIC ones are not.
So to find the numeric value of a digit character, it is always safe to subtract the base case
char digit = '4';
int number = digit - '0';
int(orunsigned) or larger type... sochar - int(your code -- [trysizeof '0'to see for yourself that'0'is not a char]) gives anint...char - chargives anint...char + shortgives anint...char * chargives anint...charare basically integers, and to each integer is attributed a character'0'to'9'specifically isn't implementation-defined. They are a special case.