void printSpaced(string s);
This function prints a string with a space inserted in between
consecutive characters. Thus, "wash" gets printed as if it were
"w a s h".
string mkShadowString(string s);
Given a string, this function returns a string of the same length, but
consisting solely of underscores (_'s). For example, "food" will
be shadowed into "____".
string uncover(string original, string covered, char c);
All occurrences of the character c within string original
will be uncovered from string covered. Here, original and
covered have the same length. For example, we will have
original covered c output
"housepet" "_______" 'e' "____e_e_"
"hello" "_e___" 'l' "_ell_"
It is easy to see why this function would be useful for implementing Hangman.
string crossOut(char c, string s);
This function crosses out the input character c from the input string s, and
returns the result string. For example, if you cross out character 'e' from
string "get", we will have string "g*t".
Submit: ~/bin/submit -c=IC210 -p=lab08 lab08.cpp
Before you start:
On the right is an example run of what you need to create.
If the number of guesses hits zero, then instead print "You lose!!!!". It thus ends with two possible outputs:
You win!!!! The word was THEWORD You lose!!!! The word was THEWORD
Your program must first choose a random word from the file
words07.txt at the start of the program. You can hardcode this
file name into your program.
How do you pick a random number? Recall that you first need a seed value that you will get from the user, and then get a random number like so:
int seed;
cin >> seed;
srand(seed);
int n = rand() % 1466;
We will choose one of the 1466 words from words07.txt. In
other words, you must read the nth word from that file where n is your random
number! Start counting the words in the file at 0, as
usual. That is, if n is 0, it means that the first word has been chosen in the
file. You'll also need to include cstdlib for these rand functions.
Other details that you must follow:
'\t') to make space between
the remaining guesses and the pad abcdedfhijklmnopqrstuvwxyz.
That is,
Wrong guesses remaining: 5\t*bcd*fghijklmn*pqr*t*vwxyz
Submit: ~/bin/submit -c=IC210 -p=lab08 lab08.cpp hangman.cpp