replacing individual chars in a string array
Hi everyone...I'm trying to right the function that puts the correct letters in the right positons being reported from my previous compareletter function for my game of hang man and its not updating the word in progress array.
Here's my compare letter function that's working correctly:
Code:
//function that returns the index of the letter that the user has guessed or
Code:
//-1 if the letter isn't in the word
int CompareLetter(char array[], char guess, int numLetters)
{
int i;
for (i = 0;i < numLetters; i++)
{
if(array[i] == guess) {
return i;
}
}
return -1;
}
So now that I have the correct position , I have an array with a series of asterisks that I would like to replace the position of the asterisk with that of the correct letter.
Code:
//updates the word in progress array with correct guesses
void updateWIP (char array[], char guess, int result)
{
if (result !=-1)
array[result] = guess;
}
However, this isn't changing any of the position of the asterisks in the word in progress array positions 0-3. Any ideas?
Thanks.