Question: Please help create the following program in C. Topics: User defined functions, character arrays, C style string member functions. Synopsis: You will write an interactive
Please help create the following program in C.
Topics: User defined functions, character arrays, C style string member functions.
Synopsis: You will write an interactive C program that will allow a user to play the Hangman game.
How to play the game:
Allow the user to guess letters one character at a time
At every stage of the game, the user should be able to view the current state of the word in progress (star word) and the list of guessed letters
If a letter is correctly guessed the player is notified and the letter appears in its proper location in the star word array
If a letter is not correct, the number of guesses is increased
In ALL cases, the guessed letter should be added to the array for guessed letters
The user is allowed up to 6 incorrect guesses
The round of the game will end when the user has either guessed the word correctly or has made 6 incorrect letter guesses
If the player guesses the word correctly, the player is notified that they have won and the correct word is displayed
If the player does not get the correct word, the player is notified that they have lost and the correct word is displayed
When the game is over, the user should be allowed to play again without having to execute the program again. (The player will play again with the next word in the file)
Instructions:
You will read the word to be guessed from a file words.txt which should contain upper and lower case words
You will use 4 character arrays o one for the word to be guessed (which comes from the input file) o one for the star word (same length as the word to be guessed) ! remember to add the NULL character : \0 o one for all of the guessed letters ! remember to add the NULL character : \0 o one for the users guess
Declare any additional variables needed
At the beginning of each game: o word to be guessed array - start with an empty string ! Read a word from the file and store it in the word to be guessed array o word in progress array should be adjusted to the correct length (that is the same size as the word read from the file but consists only of * (asterisks) in the beginning (star word) o guessed letters array should be empty a character is added with each guess
An integer will keep track of how many characters are in the array
You must have at least 8 user-defined functions with meaningful names that perform the following tasks:
1. A function that displays the rules/instructions on how to play the game
2. A function that determines if the player would like to play again (y or n)
3. A function that plays one round of the game
4. A function that turns any character array into all upper or lower case letters
5. A function that creates the star word (array of * the same size as the word)
6. A function that gets the users letter guess and adds it to the guessed letters array
7. A function that searches the word and replaces any asterisks in the starword with the guess character
8. A function that gets a guess word from the user, compares it to the solution and tells the user if they won You must use function prototypes placed before the main function and all function definitions must follow the main function. All function prototypes and definitions must have a comment describing what the function does.
Additional Requirements:
Do NOT use global variables
Do NOT use break statements to stop loops
Indent your code properly (refer to the textbook and sample code)
Place adequate comments throughout your code
Use meaningful variable names
Sample Output:
WELCOME TO HANGMAN!
Please read the following instructions before you play.
-You will be presented with a word to be guessed
-Guess letters one at a time
-You can have up to six incorrect letter guesses
-You can only guess the word when you have made a correct letter guess
-The game will be OVER when you have guessed the word correctly
Or when you have guessed letters incorrectly SIX times.
HAVE FUN!
Here are the letters guessed so far:
*********
Guess a letter: n
-------------------------------
The letter was in the word, you can now guess the word:
*N*******
Guess the word: answering
That is not the correct word
Here are the letters guessed so far: N
*N*******
*code keeps going*
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
