Write a C++ program called wh.cc that
helps you match hangman or crossword-puzzle words.
Your program reads in a dictionary of words. The dictionary used in the sample run is here. It has the concept of a current “guess”, which is of a fixed length. Initially, all letters in the guess are undetermined, but some letters can be determined by the user.
% g++ wh.cc
% ./a.out
'h' for help
? l 5
_____ has 0 matches.
? h
l <len>: set length
d <filename>: read a new dictionary
a <letter> <positions>: add letter to the given positions
w: show all words that match
c: clear the guess to all underscores
h: show this help listing
q: quit
_____ has 0 matches.
? d common-words.txt
There are 4342 words.
_____ has 687 matches.
? ae4
____e has 150 matches.
? a t0
t___e has 12 matches.
? a h 1
th__e has 5 matches.
? w
these
those
theme
three
there
th__e has 5 matches.
? ae2
the_e has 3 matches.
? w
these
theme
there
the_e has 3 matches.
? r
Invalid command!
the_e has 3 matches.
? c
_____ has 687 matches.
? q
c command were given.
l command
is given, except as shown in the example above.
a command are a space-separated list of integers.
a command says <letter>, it means one letter a-z or A-Z.
.eof() method will result in the loss of several points.
grep would make this too easy.
If you have any questions about the requirements, ask. In the real world, your programming tasks will almost always be vague and incompletely specified. Same here.
How to submit your homework:
How to receive negative points: