Scanf skips every other while loop in C

前端 未结 10 1847
清歌不尽
清歌不尽 2020-11-22 01:55

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

10条回答
  •  后悔当初
    2020-11-22 02:05

    scanf(" %c", &fooBar);
    

    Notice the space before the %c. This is important, because it matches all preceding whitespace.

提交回复
热议问题