Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

exiting!

Options
  • 26-03-2002 10:47pm
    #1
    Closed Accounts Posts: 64 ✭✭


    yes...once again i gone and got myself problems!!

    i have a program here which i am having a bit of difficulty with! i'm using a simple switch statement for a menu but the exit part wont work properly...if i go into my program and hit the exit option straight away it will break out but if i go in and use other options, then navigate back to my main menu and try to exit it goes to about 7 other screens b4 it actually breaks out! naturally i cant find the problem and it's annoying me!! the switch statement i am using is posted below...please help me!! :(


    void mainMenu()
    {
    int choice;


    do
    {
    clrscr();
    scr_outline();

    gotoxy(30,4);
    printf("Main Menu");
    gotoxy(20,10);
    printf("1. Staff");
    gotoxy(20,11);
    printf("2. Customers");
    gotoxy(20,13);
    printf("3. Exit from system");
    gotoxy(20,15);
    printf("Please enter choice: ");
    scanf("%d", &choice);

    switch (choice)
    {
    case 1:
    {
    staff();
    break;
    }
    case 2:
    {
    customer();
    break;
    }
    case 3:
    {
    break;
    }
    default:
    {
    default_scr();
    }
    }
    }while (choice!=3);
    }


Comments

  • Registered Users Posts: 1,481 ✭✭✭satchmo


    nothing wrong with what you've got there, it must be something to do with one of the functions you haven't listed.


  • Closed Accounts Posts: 64 ✭✭wee_lady


    see thats wot i thought! the main menu is the only screen i have that has an option to exit...all the other screens go back to the main menu ok but it still wont exit! head wrecking stuff i'll tell ya!


  • Closed Accounts Posts: 64 ✭✭wee_lady


    rite after going thru my code MANY times...i have realised that when i go to other screens and then back to my main menu...when i go to exit it takes my back to all the other options i have previously chosen! n e 1 have n e ideas how on this earth i managed to leave something out/put something in that would do this??!


  • Registered Users Posts: 2,781 ✭✭✭amen


    well I took the code you posted and tried on my machine it all works fine. Maybe you are doing something strange in the functions ? Can you post all your code or pm me.

    I did notice that you have no break; statement in the default (strictly not required but good idea for consistancy)


  • Registered Users Posts: 1,931 ✭✭✭Zab


    Originally posted by wee_lady
    rite after going thru my code MANY times...i have realised that when i go to other screens and then back to my main menu...when i go to exit it takes my back to all the other options i have previously chosen! n e 1 have n e ideas how on this earth i managed to leave something out/put something in that would do this??!

    Yes!

    At the end of the method's that run the sub menu's ( like staff() ), do you just return to get back to the previous menu, or do you call the mainMenu() method? You should just be returning.

    Zab.


  • Advertisement
Advertisement