So I have to write a guessing game code and I'm having some real trouble with it any help would be awesome. Whenever I compile and run the code I get the error "too few arguments to function `void GiveHint(int, int)'" Anyway the idea of this code is to use a function and then call it in int main. I'm not trying to generate a random number I'm just coding that number in. Here is my code thanks.
P.S. This is probably a stupid or novice mistake but thanks!
In your main() function you call a GiveHint() method with NO parameters.
However on line 7 you have told the compiler about a GiveHint() function that takes TWO parameters.
In your function you shouldn't set the input values like you're doing now. You pass these in when you call the method on line 33.
e.g.
1 2 3 4 5 6 7 8 9 10 11 12
main()
{
int theSecret = 47;
int theGuess = -1; //initialise it to something.
// Ask the user for his/her guess, set the value of theGuess to this.
// Call function like this:
GiveHint(theSecret, theGuess)
}
Thanks for the reply but the part where you set the guess as -1 I'm having the user input the guess so how would I do that something isn't clicking for me today. I issued the cin statement for the user to input the guess. Frankly all of this function stuff and parameters has been confusing me.
To have a user enter a value and store it in "theGuess", a simple cin>>theGuess; should do the trick. That value can then be passed into "GiveHint" as mutexe showed.