The following simple program would give an endless loop when the input is a character, though it meant to tell a character from a digit. How to test if scanf gets a
scanf
You get an infinite loop because scanf doesn't consume the character, so the character will never leave the input buffer.
You can solve it by reading a line with e.g. fgets and then use sscanf on the line.
sscanf