I’m doing a project for my C++ college class and while it’s very close to working, I am running into an annoying glitch.
As part of the guidelines, the program will take user entered data from a prompt and process via a series of loops and if else statements. It is also supposed to discard bad data(in this case negative numbers) and then bring back the prompt for the user to re-input his answer and to keep doing so until he does it correctly. I’ve succesfully done that but now have a new problem.
When I test it and type in a non-numerical character(say, a letter or a symbol), the program goes into an ifinite loop and I have to control-C out of it.
I know I have to tell the program to loop properly and go back to the input prompt (“Enter number here”) if a non-numerical character is entered. At the moment though, I’m somewhat at a loss as to how to accomplish this in a fairly simple way. I’ve been going through the textbook but nothing is jumping out at me.