GUESSING GAME ! no duplicate guess, how ???

It's hard to explain without example, please check the code then the question is on the bottom, thank you.

gameNumber receives a random number from the main.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
int getGuess(int gameNumber)
{
    int guess, tries=1;
    bool found = false;
    cout<<"\nEnter your guess: ";
    cin>>guess;
    if(!found)
    {
        while( guess > 100 || guess < 0 || guess != gameNumber)
        {
            if(guess < gameNumber)
            {
                cout<<"That's too low !"<<endl;
            }
            else if(guess > gameNumber)
            {
                cout<<"That's too high !"<<endl;
            }
        cout<<"Enter your guess: "<<endl;
        cin>>guess;tries++;
        if(tries==GAME_TRIES)
        {
            cout<<"You have run out of tries"<<endl;
            cout<<"Number of tries = "<<tries<<endl;
            cout<<"Game number is = "<<gameNumber<<endl;
            cout<<"\n\n";
            tries=0;
            found=true;
            guess=gameNumber;
        }

        }
    }
    else
    {
        cout<<"Congratulations! ! You have guessed the game number\n";
        cout<<"Number of tries = "<<tries<<endl;
        cout<<"Game number is = "<<gameNumber<<endl;
        cout<<"\n\n";
        tries=0;
    }
    return guess;
}


OUTPUT EXAMPLE:
Enter your guess: 6
That's too low
Enter your guess: 7
That's too low
Enter your guess: 8
That's too low
You have run out of tries
Number of tries = 3
Game number is = gameNumber(RANDOM NUMBER FROM MAIN)

I want to do this,

Enter your guess: 7
That's too high
Enter your guess: 7
You already guessed that
Enter your guess:


please help I have no idea how to do it
Last edited on
You might want to store guess values in a vector and check through that vector every time you receive input from user.
what is GAME_TRIES suppose to be? I've tested this code and believe it is incomplete
1
2
3
4
int prev = 0;
prev = gameNumber;
if ( prev == gameNumber);
std::cout << "You already guessed that; 
Topic archived. No new replies allowed.