Scanf skips every other while loop in C

前端 未结 10 2122
清歌不尽
清歌不尽 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:14

    A couple points I noticed:

    • scanf("%c") will read 1 character and keep the ENTER in the input buffer for next time through the loop
    • you're incrementing i even when the character read from the user doesn't match the character in secretWord
    • when does covered[j] ever get to be '-'?

提交回复
热议问题