Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Make the program return to the last......

cout<< "Enter"<<endl;
cout<< "Username: ";
cin>>user;
cout<<"Okay, you want to add " << "'" << user << "'" << "?" << "(Y or N)" << endl;
cin>>yorn;

if (yorn == "y")
{
cout <<"fasd"<<endl;
system("pause");
return 0;
}

else HOW can I make the program return to
{ to the last question asked after the
cout<<"Return??"<<endl; user responds "n"?
system("pause");
return 0;
}}
[667 byte] By [akk] at [2007-11-11 7:46:07]
# 1 Re: Make the program return to the last......
encapsulate your last question in a loop (instead of doing if-else), like:

do
{
// your last question here

cin>>yorn;
} while (yorn != "y");

And use _strlwr(yorn) is in my opinion better (not to worry about upper or lower case)
hprasetya at 2007-11-11 21:01:52 >