Question: hangmanc hangman is a wordguessing game in hangman a word...
Hangman is a word-guessing game. In Hangman, a word is chosen. You are shown a sequence of blanks, one for each character, so you know how long the word is. You must guess the word by guessing which letters are in it.
Every time you guess a letter correctly, all copies of that letter are revealed. If you guess all the letters, or if you guess the word, you win.
Every time you guess a letter or the word incorrectly, you get a strike. When you get five strikes, the game is over and you lose.
- Pick a random word from the dictionary (see below).
- Alternatively, if argc > 1, use argv as the word instead.
- Tell the player how many letters there are in the word.
- In a loop:
- Show the current state of the word (see the interactions above to see how to print it out).
- Ask the user for a letter or word.
- If they didn’t type anything, go back to the previous step and ask them again.
- If they typed a single letter,
- If it’s in the word at least once, mark all instances of that
letter as “revealed”.
- If all the letters are revealed, they win, and the program is over.
- If it’s not in the word, they get a strike. Show how many strikes they have.
- If it’s in the word at least once, mark all instances of that letter as “revealed”.
- If they typed a word (more than 1 letter),
- If it’s correct (equal to the word you picked), they win, and the program is over.
- If it’s not correct, they get a strike. Show how many strikes they have.
- If they have 5 strikes, they lose, and the program is
- Show them the correct word.