-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.c
55 lines (48 loc) · 1.32 KB
/
menu.c
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <conio.h>
static int selection = 0;
void displayMenu() {
system("cls");
printf("Program started.\n");
printf("%c Display info menu.\n", selection == 0 ? '>' : ' ');
printf("%c Display command.\n", selection == 1 ? '>' : ' ');
}
int main() {
displayMenu();
while (true) {
if (_kbhit()) {
int ch = _getch();
if (ch == 0 || ch == 224) {
switch (_getch()) {
case 72:
selection = (selection - 1 + 2) % 2;
break;
case 80:
selection = (selection + 1) % 2;
break;
}
displayMenu();
} else if (ch == 13) {
break;
}
}
}
if (selection >= 0) {
switch (selection) {
default:
case 0:
printf("This is the info menu.\n");
break;
case 1:
printf("This is the command menu.\n");
break;
}
}
printf("Press ENTER to close the program.\n");
getchar();
printf("Program ended.\n");
return 0;
}