Thread: Returning to a menu

  1. #1
    Registered User
    Join Date
    Feb 2009

    Returning to a menu

    I have another problem,and that is after let's say you have three options,and you choose one in which there's a dead end,how do you make it return to the menu,so you can try again,instead of letting the program exit?

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    what works best is something like:
    while (1) {
    // All your other stuff.

  3. #3
    Super Moderator
    Join Date
    Sep 2001
    Wrap your whole program in a loop that only exits when you explicitly set some 'exit variable' to a certain value. At the beginning of the loop have your main menu, so that any execution path that would result in accidentally ending the program just returns you there. Problems like this could be a sign that you'd benefit from restructuring / refactoring your code into pieces that make sense. That's hard to do without really understanding all your code though - so it's just a suggestion.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM