My assignment for c++ class is to create a hangman type game in which the user is given 20 chances to guess the letters of a 10 character word. I have two char arrays, one with the correct word, the other (mystery) with a series of these: "**********". As the user correctly guesses letters, the mystery array replaces the "*" element with the correctly guessed letter. i.e.: "You revealed a letter! *****s**** You have 19 more guesses."
I am using a linear search, which is working properly, but I've been scouring youtube, my text, this forum, etc for how the heck to get the mystery array to replace the "*" with the correct letter and am having zero luck. Any insight in the right direction would be so helpful. Key terms I can search, anything! I thought maybe pointers? But I can't seem to get that to work. Please help. This must be a char array and we're not supposed to use string.
// declarations and other things up here
w_size = sizeof(word); // word is the char array with the word
for (int i = 0; i<w_size; i++)
{
if word[i] == letter // letter is the user's guess
{
mystery[i] = letter;
break;
}
else
{
continue;
}