cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Validating user input using try-catch wi
Validating user input using try-catch with reprompt
Nov 3, 2010 at 4:23pm UTC
eruina
(6)
Hi all,
To handle invalid user input, I usually just loop to reprompt until the input is valid.
But my assignment details states that I need to catch multiple exceptions using try and catch.
I'd still like to reprompt the user but how do I use them in a loop without using continue.
Encasing try-catch in a loop, and setting a boolean in the catch blocks makes the exception handling superfluous.
Is there a better way to implement this?
Many thanks in advance :)
Nov 3, 2010 at 9:24pm UTC
Duthomhas
(13206)
...yes, don't use
try
...
catch
at all when forcing the user to input properly...
It seems you have a very good handle on what is necessary to handle the possibilities. You should go ask your professor what it is he would like to see.
Sorry, and good luck!
Nov 4, 2010 at 9:19pm UTC
eruina
(6)
Aw shucks.. I'll try to catch my prof then
Thanks for the reply! :)
Topic archived. No new replies allowed.