I am coding hangman for a project. My teacher supplied us with this code:
Code:
string show_hidden_letter(string secret, string hidden, char guess)
{
string result = hidden;
for (unsigned i = 0; i < result.length(); i++)
if (secret[i] == guess)
result[i] = guess;
return result;
}
It is suppose to return the hidden word with the correct words the player guessed revealed.
Now what I am stuck on is how to use this function. I have declared the prototype at the top already and have the function underneath the int main.
How do we use this function in int main?
I am the random word picked by the computer as "word", the word replaced with stars as "secret", and the letter chose by the person as "a".
So I know it involves something like this in the int main:
show_hidden_letter(word, secret, a) but I don't know how to use it nor how to cout the new updated version where the correct letter is revealed.
Please help me with this. I am not looking to be spoon fed but is willing to learn how to use this function properly. Thank you in advance.