#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int x;
cout << "Press the number 1, 2 ,or 3";
cin >> x;
while (x!=1){
cout<<"Please try to pick a difference selection.";
cin>>x;
}
if ((x==1) {
cout<<"\nYou chose ";cout<<x;
}
system("PAUSE");
return 0;
}
hey all im new to c++ and just playing around with the while loop and if statements. my question is how can i make it so if the user inputs anything other than 1, 2, or 3 it asks them to try again without crashing. it didnt crash when incorrect small integers were entered but when i put in a char it crashed in an endless loop.