[Solved] function not stopping [closed]


Your problem comes from a bad use of switch/case. See Switch/Case documentation. Your menu switch/case will triggered every cases

switch(1) {
    case 1 : cout << '1'; // prints "1",
    case 2 : cout << '2'; // then prints "2"
}

and

switch(1) {
    case 1 : cout << '1'; // prints "1"
             break;       // and exits the switch
    case 2 : cout << '2';
             break;
}

Your code should look like this :

 switch(menu){
    case 1:
        add();
        break;
    case 2:
        display();
        break;
    case 3:
        del();
        break;
    case 4:
        popall();
        break;
    }

With this code you won’t need a while at the end of your switch. Your while loop is infinite because if you type 1, it will triggered add() menu again and again because while(menu!=5); is always true unless menu=5

4

solved function not stopping [closed]