My expected code:
Code:
string s1="end";
do {
cout << "Enter name:";
cin >> name;
if (name==s1) //this is working
break;
//while ((name doesnt has alphabets))
cout<<"error"
<<"ur string has a number in it"<<endl;
cout<<"please re-enter the name"<<endl;
cin>>name;//
this is my first doubt..
also there is a minor bug,which is buggin me ,as per ur previous code for checking ONLY int ,
Code:
cout << "Enter 1st time:";
cin >> a_time;
while (cin.fail())
{
cin.clear();
cin.ignore (buffer, '\n');
cout << "pls re-enter number";
cin >>a_time; //now for eg if i type 12A the output is "enter 2nd time", pls re-enter number" ie. how should i avoid getting the display message"enter 2nd time"??//
}
cout << "Enter 2nd time:";
cin >> b_time;
while (cin.fail())
{
cin.clear();
cin.ignore (buffer, '\n');
cout << "pls re-enter number";
cin >>b_time;
}
thanks ......