I\'m trying to develop a simple text-based hangman game, and the main game loop starts with a prompt to enter a guess at each letter, then goes on to check if the letter is
The first time through the loop, scanf() reads the character. Then it reads the newline. Then it reads the next character; repeat.
I seldom use scanf(), but if you use a format string "%.1s"
, it should skip white space (including newlines) and then read a non-white space character. However, it will be expecting a character array rather than a single character:
char ibuff[2];
while ((scanf("%.1s", ibuff) == 1)
{
...
}