I am kind of a beginner and have a little problem when trying to loop a menu.
Let's take this for example:
int option = 0;
do {
printf("Menu\n");
printf("[1] Insert\n");
printf("[2] List\n");
printf("[0] Exit\n");
printf("\nOption: ");
scanf("%i",&option);
switch(option)
{
case 1: {
// code
break; }
case 2: {
// code
break; }
default: {
// error
}
}
} while(option != 0);
This will work for numbers, yet, as the option is an integer, if the user types a text, such as "a" or "owkefok" or even "ewf432k", the program will just break;
How do I give an error such as if(containstcharacters) then(error) while repeating the menu? Is it possible without changing the option to char?