Looping a switch statement

How can I make the default statement in a switch, loop back to the first case and reprint the cases if the user failed to press a valid option?
Reprint the cases? I'm not sure what you mean.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...
int opt = 0;

do
{
 cout << "option 1-5:";
 cin >> opt;

 switch(opt)
 {
  case 1:
   instructions..
  break;
  case 2:
   instructions..
  break;

   bla bla

  default:
   cout << "There wasn't valid option. Please type again your option or 0 means the exit."
 }

}while (opt != 0); // 0 means the quit


Ok, that works but it only catches numeric errors...

How can I make this program catch any type of error? Or maybe convert the error into a number and then display an error message?
http://www.cplusplus.com/forum/articles/6046/
Good ways to get input correctly.. see if this helps :)
Topic archived. No new replies allowed.