Help w/ replacing characters in str w/ letter(char)?

Can someone please help me understand how to replace the character found with size_type variables in a string variable with a letter(char) inputted from the console. I am working on a hangman word-game and just need to get this part to work. Here is the code I have. Thanks in advance.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void show_Hidden_Secret_Word(string& word)
{
	get_Secret_Word(); 
	
	cout << "\n" << endl;
	cout << "Please enter the letter you wish to guess" << endl;
	char guess;
	cin >> guess;

	size_t found = word.find_first_of(guess);

	if (found == string::npos)
		cout << "Sorry! There are no " << guess << "'s in the word." << endl;

	while (found != string::npos)
	{
		word[found] = guess;
		found = word.find(guess, found + 1);	
		cout << word << endl;
	}
}
The only part of this that looks suspicious is the call to get_Secret_Word(). You aren't expecting it to fill out the "word" parameter to show_Hidden_Secret_Word(), are you?
Topic archived. No new replies allowed.