Controlling User Input

Help. I am working on a final project that stimulates an ATM machine. My professor tested it and found that it causes an infinite loop if he entered a character rather than a number for what I had set up to be menu choices. I cant really find anything that works.
cout << "Please enter your PIN\n" << endl;
cin >> pin;
while((pin < 1000)||(pin > 9999))

cout << "Invalid PIN\n" << endl;
cout << "Renter PIN\n" << endl;
cin >> pin;

you have it backwards
try this
((pin >1000)||(pin < 9999))
I am trying to control the input of characters anyway. It is actually the correct conditions that I wanted.
Last edited on
Topic archived. No new replies allowed.