switch default without "goto"

Jan 30, 2011 at 4:34pm
How should I use default case on switch without goto? I mean, if user's input is invalid, and I want user to type input again, how should I do that? Previously I used goto xxx; -statements, but everyone keeps saying that goto -statements are bad programming.
Last edited on Jan 30, 2011 at 4:34pm
Jan 30, 2011 at 4:45pm
Use a while statement...
Jan 30, 2011 at 6:23pm
1
2
3
4
do
{
  get_user_input();
}while( user_input_is_not_valid );
Topic archived. No new replies allowed.