Letter guessing game solution

You will write a C program that will play a letter guessing game.
General Requirements
 Write a program that reads letters from a file called“lettersin.txt”.
 Your program will ask the user to enter the number of games they wish to play (1 to 4)
 Your program will open the lettersin.txt file read in one character at a time and repeat this for the
number of games the user wants to play.
 For this assignment the test file will contain letters, all lowercase
 When the number of games has been played, the program will end
 A sample of an input file that you can use to test your program is included with the assignment.
 A preprocessor directive must be used to define the maximum number of guesses as 5
 If the player has used up all of their guesses, a message that the game is over should be displayed
along with the letter they were trying to guess.
 You must have at least 4 user defined functions as follows:
//this function provides instructions to the user on how to play the game
void GameRules( );
//this function runs one entire game. It for checks either 5 incorrect guesses or a correct guess.
//It returns a 0 if the game is over and the player did not guess the letter, otherwise it returns 1.
int SingleGame(char file_letter);
//this function prompts the player to make a guess and returns that guess
//this function is called from inside the SingleGame( ) function described above
char RetrieveGuess( );
//this function takes two arguments, the guess from the player
//and the solution letter from the file.
//It lets the user know if the guess comes alphabetically before or after the answer
//The function returns 1 if the guess matches the solution and returns a 0 if they do not match
//this function is called from inside the OneGame( ) function described above
int GuessedIt(char answer, char input_letter);
Additional Requirements:
 Use function prototypes.
 Write comments for each function that will appear in the file before each prototype and
again before each function definition.
 Be sure to comment your code adequately.
 Be sure to indent properly. Check your textbook and lecture code examples to see how it should
be done.
 Use meaningful variable names
 Check all requirements list on Blackboard before submitting
Sample Output:
Welcome to the Letter Guessing Game
You will enter the number of games you want to play (1 - 4 games)
You have 5 chances to guess each letter
Let's begin:
--------------------------------
How many games do you want to play (1-4) 3
************************************
Let's play game 1
Enter a guess: e
the letter you are trying to guess comes before e
Enter a guess: c
the letter you are trying to guess comes before c
Enter a guess: a
You guessed it!!!
************************************
Let's play game 2
Enter a guess: t
the letter you are trying to guess comes before t
Enter a guess: a
the letter you are trying to guess comes after a
Enter a guess: p
the letter you are trying to guess comes before p
Enter a guess: n
the letter you are trying to guess comes before n
Enter a guess: g
the letter you are trying to guess comes after g
You did not guess the letter. It was m
************************************
Let's play game 3
Enter a guess: g
the letter you are trying to guess comes after g
Enter a guess: m
the letter you are trying to guess comes after m
Enter a guess: t
the letter you are trying to guess comes before t
Enter a guess: r
the letter you are trying to guess comes before r
Enter a guess: s
the letter you are trying to guess comes before s
You did not guess the letter. It was n
Press any key to continue . . .
Powered by