Advice c++ Menu

Hi,

Currently I'm trying to create a (console) menu in c++, everything works fine (I think). It's not finished but I would like to ask if someone has advice or tips to improve the code.

Bas

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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <iostream>
#include <string>
#include <Windows.h>
#include <cstdlib>
using namespace std;

int main(){
    //VALUES
    int menumax = 0;
    int menuvalue = 1;
    int back = 0;
    
    //MENU START
    cout<<"[----MENU----]"<<endl;
    cout<<"[>>] START"<<endl;
    cout<<"[] SETTINGS"<<endl;
    cout<<"[] EXIT"<<endl;
    cout<<"[------------]"<<endl;
    
    //MENU + APPLICATION
    while (true)
	{
            if (GetAsyncKeyState(VK_UP)){
                if(menumax==1){
                    system("cls");
                    cout<<"[----MENU----]"<<endl;
                    cout<<"[>>] START"<<endl;
                    cout<<"[] SETTINGS"<<endl;
                    cout<<"[] EXIT"<<endl;
                    cout<<"[------------]"<<endl;
                    menumax = 0;
                    menuvalue = 1;
                    Sleep(100);
                }else{
                    if(menumax==2){
                    system("cls");
                    cout<<"[----MENU----]"<<endl;
                    cout<<"[] START"<<endl;
                    cout<<"[>>] SETTINGS"<<endl;
                    cout<<"[] EXIT"<<endl;
                    cout<<"[------------]"<<endl;
                    menumax = 1;
                    menuvalue = 2;
                    Sleep(100);
                    }
                }
            }
            if (GetAsyncKeyState(VK_DOWN)){
                if(menumax==0){
                    system("cls");
                    cout<<"[----MENU----]"<<endl;
                    cout<<"[] START"<<endl;
                    cout<<"[>>] SETTINGS"<<endl;
                    cout<<"[] EXIT"<<endl;
                    cout<<"[------------]"<<endl;
                    menumax = 1;
                    menuvalue = 2;
                    Sleep(100);
                }else{
                    if(menumax==1){
                    system("cls");
                    cout<<"[----MENU----]"<<endl;
                    cout<<"[] START"<<endl;
                    cout<<"[] SETTINGS"<<endl;
                    cout<<"[>>] EXIT"<<endl;
                    cout<<"[------------]"<<endl;
                    menumax = 2;
                    menuvalue = 3;
                    Sleep(100);
                    }
                }

            }
            //IF USER HAS CHOSEN FROM MENU.
            if (GetAsyncKeyState(VK_RETURN)){
                switch(menuvalue){
                    //STARTING APPLICATION
                    case 1 :
                        cout<<"DONE"<<endl;
                    break;
                    //SETTINGS
                    case 2 :/*
                        while(back==0){
                            system("cls");
                            cout<<"[----SETTINGS----]"<<endl;
                            cout<<"[] START"<<endl;
                            cout<<"[]"<<endl;
                            cout<<"[] BACK"<<endl;
                            cout<<"[------------]"<<endl;
                        }
                        back = 0; */
                    break;
                    //EXIT APPLICATION
                    case 3 :
                        return 0;
                    break;
                    //INCORRECT VALUE
                    default :
                        cout<<"ERROR";
                    break;
                        
                }
            }
            Sleep(100);
            
	}
    return 0;
}
Topic archived. No new replies allowed.