I am trying to write a while loop that exists the while loop when i select actres or movie title. But for some reason its not working its telling me there is an error in the while (selecton) line. Anyone have an idea?
string selection;
while ( selection )
{
cin >> selection;
if ( selection == "actress" )
{
cout << "hey" << endl;
break;
}
else if ( selection == "movie title" )
{
cout << "bye";
break;
}
else
{
cout << "Please choose a selection";
}
}
It’s supposed to be
while(cin>>selection)However it’s better to write
while(getline(cin,selection))so you don’t skip white lines.