So I have to create a hangman program that randomly chooses a word from a word bank, the user guesses it, and the programs repeats. No physical hangman has to be drawn the program just has to keep track of wrong/right guesses.
This is what I have so far I'm having some trouble figuring out how to add the word bank into the program. Also trying to figure out how to track wrong guesses. Any help is appreciated. Thanks.
[Wordbank] = read random word from file (or if you have to, create an array of words in the program itself)
another hint, if(letter!=word) will not work as (assuming) word stores the entire word (that means word should be declared as string word and not int word) and you are reading a letter
First let me state im still very new at C++ and programming in general and I might be wrong with these ideas. But im just going to brainstorm with you cause this problem interested me.
For the wordbank im thinking you can use a container like a vector or something to contain the words. Im guessing you only need like 10 different words or so. Just put 10 or more words into a vector and that can be your wordbank.
this is the part im not so sure about, to randomly pull a word out of the bank im thinking you can probably use the random number generater rand(); to pull a random word out of the wordbank vector. Im not sure if rand() works on a vector and am at work so cant try it out atm.