For this assignment, you are to write a program that plays the game of Hangman. The assignment serves two purposes.
First, it is designed to give you practice with strings, pointers and file I/O. Second, it gives you a chance to write a program
that is larger than those you have written for most previous assignments. Large programs require more up-front organization
than small programs, and it is important that you begin to get experience with larger programs at this point in the course.
Because of the additional organizational work and the fact that there are more details to manage, you are strongly
encourage to work in teams of two for this assignment. For your version, you will use phrases rather than single words for
the user to guess
You must choose a phrase randomly from a dictionary file. Dictionary files will contain some number of lines,
each line contains a phrase, as shown below. The number of words per file may vary, as will the maximum
number of characters in any line. Your program should prompt the user for the name of a dictionary file to use. It
should then open the file, count the number of lines, count the largest number of characters in any single line,
and then randomly select one line to read in. You should dynamically allocate enough space for the randomly
chosen line based on what you know about the size of the largest word in the file. You should create a phrase
file with an end-of-line character at the end of the last line in the file. An input file might look like:
One good turn deserves another
She gets confused flying over the dateline
If I can't dance I don't want to be part of your revolution
A rolling stone gathers no moss
Nothing in all the world is more dangerous than sincere ignorance and conscientious stupidity
hello, Is anybody out there?
ou are NOT ALLOWED to use the book's libraries strlib.h or simpio.h for this assignment. Instead, you must rely
on C's standard set of string-manipulation functions, provided by the string.h library, and C's standard set of input
and output functions, provided by the stdio.h library.
Grading
Part of your grade on this program will be style. To receive an A, your program must have good modular design and good
use of data structures. Also, your code should be efficient and well commented.
Submission
For extra credit:
Use the graphics library to draw an evolving picture of the game situation. Or implement a version that uses ascii graphics
(example output from the ascii graphics version can be seen on this page).
If you add graphics, you should design and test your program in two parts. First, get the interactive part working without any
graphics at all. Once that part is done, make a copy of it, and then add code to draw the Hangman picture using the
graphics library functions.
The Basic Hangman Game
Write a program that implements the hangman game without graphics. To solve the problem, your program must be able
to:
Choose a random secret word from a file.
Keep track of the user's partially guessed phrase, which begins as a list of dashes (or underscores) and then is
updated as correct letters are guessed (see sample run below). Spaces between words should be displayed, as
should any non-alphabetic characters (like punctuation); the user should only have to guess letters.
Implement the control structure of the interaction (looping for each guess, detecting the end of the game, and so
forth).
Manage the details (keep track of the number of guesses, display the right messages, and so on). Use the sample
output as a guide for the type of things your program should output at each step.
Your Hangman program should implement the following features:
Guesses should be accepted either in lower or upper case, but letters in the secret phrase should be displayed
using upper case only.
Spaces between words and punctuation should be displayed; users only guess letters.
If the player guesses something other than a single letter, your program should provide the opportunity to guess
again.
Keep track of the letters guessed so far. If the user accidently chooses the same letter again, give him/her
another chance. After each guess you should display all the letters guessed so far.
Your program should give the user the option to quit at any point in the game. If the user enters the '!' character
as the next letter guessed, your program will exit with a message indicating that the user chose to quit and will
list the word that the user was trying to guess.
The Graphics Version (Extra Credit)
For extra credit, your task is to extend the program you have already written so that it now keeps track of the Hangman
graphical display. Everything you need to draw a simple picture is available in the graphics library, or you can use ascii
graphics to implement this. Your task is simply to determine the best way to integrate the new part of the program into the
existin