Hi
I'm fairly new to c++ programming and have a simple question regarding a piece of code I have written.
I set up a do while loop as part of a simple menu that will repeat the menu if the user doesn't either enter a one or a two (the only choices available).
Below is the syntax for this code.
It works great if the user enters in a wrong number, however if he enters any sort of other character like a letter then it just goes into a neverending loop that I have to force quit.Code:
do{
cout<<"Please choose conversion type"<<endl;
cout<<"1.) Ra to RMS\n";
cout<<"2.) RMS to Ra\n";
cin>>switchn;
cin.ignore();
system("cls");
}while (!((switchn == 1)||(switchn == 2)));//end of do-while
Is there a way to set it up so that if someone enters a letter by accident it will just go throught the loop once and not continuously uninteruupted?
Thanks