Garmaine Staff asked 2 years ago
Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 3 hours ago.

so the problem is I have a text file containing several words, and I want to check if the user input is one of them. If not then the code must print a error message and loop until the user inputs a word from the text file. So the problem starts when the first input is entered wrong. Compared word stays the same as the last word of the text and I can not change it.

while(checker == false)
            cout << "There is no Pokemon called "<<p1PokeName<<". Please enter again."<<endl;
            cout <<"Player 1, please choose a pokemon: ";
                pokeAttList >> word;//this word remains same as the last word of the text file when it tries to go into a loop
                if(p1PokeName == word)
                    checker = true;
                    cout << "You chose "<<p1PokeName<<"!";