So I'm coding a "Hangman" game, where the user tries to guess a word by entering letters one at a time. Every wrong guess gets the user closer to getting "hanged". What I can't figure out though is, I have two functions apart from main(), how to return multiple values from one function. How do I do that? Look at the "searchingThroughGuess" function below.
What I can't figure out though is, I have two functions apart from main(), how to return multiple values from one function. How do I do that? Look at the "searchingThroughGuess" function below.
You can't. However, you *can* modify the function so that it will modify values passed to it. See below for an example:
1 2 3 4 5 6 7 8 9 10
void change_to_five(int& x) { //note the &, this means it is passed by reference
x = 5;
}
int main() {
int x = 3;
change_to_five(x);
//now x is 5
return 0;
}