Hi. I am trying to check that somebody has to write a specific string at the beginning and at the end. I know my problem is in the while loop expression.
Below code only will run if string is stop not Kobe stop.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
int main()
{
string name;
cout <<"Enter your name followed by stop :" ;
getline(cin , name);
while(name != "stop")
{
cout << "Invalid input. Type stop at the end." << endl;
cout<<"Enter your name followed by stop: ";
getline(cin , name);
}
return 0;
}
What if I wanted stop at the beginning or both? Thanks for the help..!!