In a menu code as the following:
Code:
void menu()
{
char opcao;
do
{
1- Insert
2- Alter
3- Search
4- Delete
5- Add
6- Multiply
7- XML
8- Sort
9- List
0- Exit
cout<<"Option: ";
cin>>Option;
switch(Option)
{
case '1' : insert(); break;
case '2' : alter();break;
case '3' : search(); break;
case '4' : delete();break;
case '5' : add();break;
case '6' : multily();break;
case '7' : xml();break;
case '8' : sort(); break;
case '9' : list(); break;
default : "...":break;
case '0' : exit(0); break;
}
}while(opcao >='0' && opcao <='9' );
}
How can i prevent the user from inserting, for instance 148, and prevent the switch to execute the 1 ,4 and 8 options at the "same time" instead of blocking the number inserted because it is out of the 0-9 range ?
Thanks