C++ keeps on glitching while using switch statement in while loop

cin >> switch1 tries to read in an integer. If you type d (which can’t be converted to an int, it doesn’t “eat” the bad input so you must clear it manually.

Try adding this to your error case:

cin.ignore(INT_MAX, '\n');

Browse More Popular Posts

Leave a Comment