I am using c and I am a newbie.
I want to get a input (1 or 2 or 3) and I will give the user suggest;
printf("please do it\n");
printf("1. \n");
printf("2. \n");
printf("3. \n");
char opt;
scanf("%c"&opt");
if opt is not 1 or 2 or 3 then
printf("error\n");
printf("please re do it");
and all is in a while(true) loop until user enter the enter(new line charactor)
to exit;
and how to do it?
I tried to create a function.
void get_order(char opt){
switch(opt){
case '1':break;
case '2':break;
case '3':break;
default:
printf("error\n");
printf("please re do it"):
char option;
scanf("%c",&option);
get_order(option);
}
}
but it not work. thank you.