1. Engineering
2. Computer Science
3. hangmanc hangman is a wordguessing game in hangman a word...

# Question: hangmanc hangman is a wordguessing game in hangman a word...

###### Question details

hangman.c

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.

1. Pick a random word from the dictionary (see below).
• Alternatively, if argc > 1, use argv[1] as the word instead.
2. Tell the player how many letters there are in the word.
3. In a loop:
1. Show the current state of the word (see the interactions above to see how to print it out).
2. Ask the user for a letter or word.
3. If they didn’t type anything, go back to the previous step and ask them again.
4. 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.
5. 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.
6. If they have 5 strikes, they lose, and the program is over.
• Show them the correct word.