Question: Write an C program game Hangman. The user has the option of entering a character to guess the other. If the entered character occurs in

Write an C program game Hangman. The user has the option of entering a character to guess the other. If the entered character occurs in the searched word, it will appear in all occurring places used. Has the character already been entered or does it appear in the If the word you are looking for is not available, a corresponding message will be displayed. The game ends when the word has been fully guessed or there are no more failed attempts left.

Select a random word: Store the words that the user can guess in a matching array and randomly choose one of them when you start the game. Use the function rand();

Handling of strings: Store the word you are looking for in a C-string. Think about how you can store the characters you have already entered as efficiently as possible. You can use functions of the library string.h to easily search for characters within a C-String ( to find out whether the character has already been entered).

Guess: Store the word guessed so far in a char array. This allows you to easily replace characters that are found. The individual letters of the word you have guessed that have not yet been revealed should be marked with a dot at the beginning. If a letter is guessed, it is put in the right place. Report the number of failed attempts remaining on each pass. If a character that occurs in the word is guessed, this does not count as a failed attempt.

An output example:

Write an C program game Hangman. The user has the option of entering a character to guess the other. If the entered character occurs

Remaining tries: 10 Please enter a character: h You entered: H Congratulations - you found a new character in the word! Word: H........ Already guessed: H Remaining tries: 10 Please enter a character: e You entered: E Congratulations - you found a new character in the word! Word: H. .E. .E. Already guessed: HE Remaining tries: 10 Please enter a character: E You entered: E You have already tried this character. Word: H. .E..E.. Already guessed: HE Remaining tries: 9 Please enter a character: x You entered: X Unfortunately, this character is not part of the word. Word: H. .E. .E.. Already guessed: HEX Remaining tries: 8 Please enter a character: sdf Please enter only one character! Please enter a character: a You entered: A Congratulations - you found a new character in the word! Word: HA.E..E.. Already guessed: HEXA Remaining tries: 8 Please enter a character: r You entered: R Congratulations - you found a new character in the word! Word: HAGENBERG Already guessed: HEXAGNBR Congratulations

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!