A quick explanation of why it works:
In C, as in many programming languages, the char datatype is basically a number. Therefore, integer comparisons are possible, even without typecasts, and using %d in a printf is also perfectly valid.
As an example, take getchar(). It's signature is
code:
int getchar(void);
It gets a character from the keyboard (stdin), and returns it as unsigned. This leaves the negative values of int free for error codes.
Put simply:
0-255 is a valid character
<0 is an error.
Edit: Of course, once you've checked it's positive, you will need to typecast into a char. char is typically 8 bits, int 16/32 bits.