Mask and demask word

Hi guys, thanks for taking the time to look at this. I'm working on a hangman game and have masked the word that the user needs to guess(code below). The fact is that this works great for masking the word but not unmasking letter by letter based on the users guess. Some simple guidance is needed here as opposed to code(although that'd be nice too). Remember, if the user gets the word right, i only need to unmask only letter they got right.
1
2
3
4
5
\	//creating a masked version of the word to guess
	for (int i = 0; i < word.length(); i++)
	{
		mask += " _";
	}
You create the mask once after the word is determined and before the guessing starts. Then you replace the guessed letters from word in mask at the position where they are in word. Determine the position of the letter with the find function:

http://www.cplusplus.com/reference/string/string/find/
Last edited on
Topic archived. No new replies allowed.