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.
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?