How to add submenu

How to add submenu
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
#include <iostream>
using namespace std;
int vtoromenu();
int main()
{
    int janr();
    void pesen();
    void izpulnitel();
    int vtoromenu();

    int choise;
    string janr1 [10];
        janr1[0]=" chalga ";
        janr1[1]=" narodno ";
    string pesen1 [10];
        pesen1[0]=" Rat srca ";
        pesen1[1]=" Lena magdalena ";
        pesen1[2]=" Graovsko horo ";
    string izpulnitel1 [10];
        izpulnitel1[0]="Mile Kitic-";
        izpulnitel1[1]="Toni i Fiki Storaro-";
        izpulnitel1[2]="Orc.Naslada-";


              {
        int choice;

        do
        {


        cout << endl
        << " 1 - Janr\n"
        << " 2 - Zaglavie\n"
        << " 4 - Izpulnitel\n"
        << " 5 - Krai na turseneto\n"
        << " Izberete vashata kategoria: ";
        cin >> choice;

        switch (choice)
        {
        case 1:
        //submenu for void janr()

        case 2:
        //submenu for void pesen ()
        break;
        case 3:

        break;
        case 4:

        break;
        case 5:
        cout << "Blagodarq che ni posetihte zapovqdaite otnovo.\n";
        break;
        default:
        cout << "Not a Valid Choice. \n"
        << "Choose again.\n";
        break;
        }

        }
        while (choice !=5);
        return 0;
}





    return 0;
}
closed account (j3Rz8vqX)
Make functions for each submenu

or

Create a generic submenu for all cases and control flow with passed parameters.

I am uncertain about what kind of submenu you are attempting to make.

An example of a recursive submenu would be:
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
#include <iostream>
using namespace std;
int menu(string address)
{
    int choice;
    do
    {
        cout<<address<<'\n';
        cout<<"What would you like to do: "
            <<"\n1) Do option 1"
            <<"\n2) Do option 2"
            <<"\n3) Do option 3"
            <<"\n4) Back"
            <<"\n5) Exit"
            <<"\nChoice: ";
        cin>>choice;
        cin.clear();
        cin.ignore(255,'\n');
    }while((choice<1||choice>5)&&cout<<"\nError! Try again:\n");
    cout<<'\n';
    return choice;
}
bool recursiveMenus(string address,string cat)
{
    bool run=true;
    address.append(cat);
    do
    {
        switch(menu(address))
        {
        case 1:
            if(!recursiveMenus(address,"->1"))
                return false;
            break;
        case 2:
            if(!recursiveMenus(address,"->2"))
                return false;
            break;
        case 3:
            if(!recursiveMenus(address,"->3"))
                return false;
            break;
        case 4:
            run=false;
            break;
        case 5:
            return false;
        }
    }while(run);
    return true;
}
int main()
{
    recursiveMenus("Start","");//Null to exploit function signature.
    cout<<"Press <enter> to exit: ";
    cin.get();
    return 0;
}
Topic archived. No new replies allowed.