Alright, I'm down to the nitty gritty absolute end of a fully functional hangman game. There is just one part where I am absolutely stuck. When you get a wrong guess, the game successfully draws the gallows. I have no issues with wrong guesses. It's the right guesses that has me stumped. Here is what I have for this:
guess(); //call member function of letter chosen
ltrpos = gameWord.find(gameGuess);
cout << "You have chosen the letter " << gameGuess << '.' << endl;
if (ltrpos < gameWord.length()) //checks letter existance in chosen random word (correct choice)
{
for (i = 0; i < gameWord.length(); i++)
{
if (gameGuess == gameWord[i])
{
cout << gameGuess;
}
else
cout << '_';
}
cout << endl;
cout << "Wow, nice guess!!! Guess another letter." << endl;
When you guess the correct letter it DOES display ALL the instances of that character in the correct places. The problem I'm having is, when it loops around to guess again, how do I keep the correct guess that was just made and add to that guess with the next correct guess while putting the NEW letters in their correct instances as well.
Example of how it is now:
Loop 1: n_n__n__
Loop 2: _i______
Loop 3: ___t____
The word here should be nintendo and it should ALSO do this:
Loop 1: n_n__n__
Loop 2: nin__n__
Loop 3: nint_n__
Suggestions?????