Using a function of type bool as a condition for while loop

Mar 5, 2019 at 4:44am
I get error (C++ forbids comparison between pointer and integer) when i used a bool function as the condition in a while loop. Can someone please help me.
The code looks something like this.

bool again()
{
char answer;
cout << "Enter y to try again: ";
cin >> answer;
return (answer == 'Y' || answer == 'y');

}

do
{
}while(again==true) // This line of code is the problem.

Thanks in advance!


Mar 5, 2019 at 4:48am
Like this.
1
2
do {
} while ( again() )
Topic archived. No new replies allowed.