I'm trying to write a menu-driven program for a final project. If the user enters a letter instead of a number, an infinite loop occurs. How do I fix it? The due date was moved up and I have several other projects and I just want to enjoy my summer :'(
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
cout << "Enter a number 1-6: ";
cin >> number1_6;
while(number1_6 < 1 || number1_6 > 6)
cout << "Enter only a number 1 - 6 : ";
Bless you. Thank you. I hope you can imagine how thankful I am. This is for a final project in my intro to programming class and my substandard teacher never even used a bool variable, let alone showed us how to do this, but is holding us responsible for it and has pushed up the due date. I'm so close to an A in the class that it hurts and I still have two other classes to deal with. this has been keeping me from sleeping at night. Now I can finally finish (maybe even on time) and go get a degree at a better school.