Hi guys i need your help.
I am a C beginner and i have a few problems with my project in C for my school.
I need to build a menu: Input 1 2 3 4 5 - for other inputs print "No!"
1 - Printf logout - Done
2 - Doing nothing just take you back to main menu - Done
3 - Scanf a question "Are you sure you would like to place your order"
The user need to input "Y" or "y" and right after that the program will quit (for other input at the scanf the program will be back to main menu) - I putted the inputs "Y" 'y" in the cases but it's wrong - I don't know how to work with scanf in a loop.
4 - I need to know how much times the program backed to main menu and write the number of "people" that used it - like if the i pressed nine times on "1" - that means that i am ten person who is using the program - i need to use "i++" some how but i don't know how to..
5- Quit the program - my problem here is that the Default printf "No!" combined with the option i don't know how to remove the printf here
The code-
Code:
#include <stdio.h>
#include <conio.h>
int main(void)
{
char ch;
do {
printf("\Enter number 1-5 : ");
ch = getche();
printf("\n");
switch (ch){
case '1':
printf("logout\n");
break;
case '2':
break;
case '3':
printf("Are you sure you would like to place your order ???\n");
printf("Please enter one char: ");
scanf("%d");
break;
case '4':
printf("Your position in queue is %d\n");
break;
case '5':
printf("");
case 'y':
printf("");
case 'Y':
printf("");
/* scanf("%c", &canceling);
switch (canceling)
{
case 'Y':
case 'y':
printf("“Canceled");
break;
default:
printf("Wrong input\n");
}*/
default:
printf("No!\n");
break;
}
} while (ch != '5');
printf("");
return 0;
}