Thanks for the reply, but that wasn't really what I was looking for. I was just looking for a way to make my updateCurrentWord() function work. This is for a project so I don't want to just copy and paste code.
If JLBorges' code doesn't supply you with what you need to solve your problem, then can you be more specific about what it is that you do need?
They've shown you a technique for identifying every character in the answer that matches the user's guess, and updating that character in the string containing the current guesses. How is that not what you wanted?
I don't think that @JLBorges was expecting you to cut and paste code. He has deliberately highlighted the parts that you need to read and understand. Within that are the implications that:
- letter is a char, not a string
- you can simply loop through your characters with a for loop and change any that need changing;
- you shouldn't be using global variables like this; pass them as reference arguments
- it's convenient to return a bool to state whether anything was changed or not. Isn't that necessary for Hangman?
I think that there is also an implication that you need to restructure your code first before simply trying to "make my updateCurrentWord() function work".
As an unrelated aside, your exception-handling meant that I couldn't compile your code.