You don't seem to be stuffing the letter! To save it!
Or some indication you have that letter within the word that was already tested!
if (gameGuess == gameWord[i]) // matching letter found?
{
myWord[i] = gameGuess; // <---- Stuff new letter
cout << gameGuess;
}
else if (myWord[i] )
cout << myWord[i];
else
cout << '_';
}
wildgoose
Practically a Posting Shark
896 posts since Jun 2009
Reputation Points: 546
Solved Threads: 99
Yes, simultaneous post. It's late here, and I noticed that after the post and editted then saw your post!
Cromarte88, you need either to store the characters you picked correctly, or store a flag for each correctly chosen character position so that letters previously chosen will be displayed!
wildgoose
Practically a Posting Shark
896 posts since Jun 2009
Reputation Points: 546
Solved Threads: 99
Method of using a double character buffer!
['H']['a']['n']['g']['T']['e']['n'] <-- gameWord[]
['_']['_']['_']['_']['_']['_']['_'] <-- gameGuess[]
As each letter guessed, the letter is copied over to same index
Only display gameGuess, not gameWord gets displayed.
wildgoose
Practically a Posting Shark
896 posts since Jun 2009
Reputation Points: 546
Solved Threads: 99
So, use a big buffer for both. Get string length of actual hangman string, fill guess string with '_' and set the ASCIIz terminator at the element corresponding to the string length.
So now they are the same length!
I said there were several ways of doing this. If you don't fully understand strings then go back and review!
wildgoose
Practically a Posting Shark
896 posts since Jun 2009
Reputation Points: 546
Solved Threads: 99
Like I posted. There are several ways of doing this! In my case, it was based upon a fixed length buffer that gets reused. In Zalezog's case, they're promoting the use of a dynamic buffer. You're having trouble with simple ASCII buffers so I felt the fixed length buffer was a good starting place. The method of using variable length buffer's such as using the string class is the more advanced but better solution. You are using C++ in your code!
wildgoose
Practically a Posting Shark
896 posts since Jun 2009
Reputation Points: 546
Solved Threads: 99