Digit recognition in C