Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts

    C#: ReRunning the program

    My program consists of mainly a switch statment that determines what task the user wants. I give the user a list of 4 task and he picks one. What I'm trying to do it make it where once the user is done with a task the program runs again without exiting. Like making the switch statment run again. Anyone know how. I tried putting the program into a function and then at the end of the function calling it self again, but it didn't work. Help

    BTW: Its a command prompt program :P

  • #2
    New Coder
    Join Date
    Dec 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    use a do-while loop.

    do {
    ...
    //switch statements
    ...
    case 4:
    exit = true;
    break;
    } while (exit == false)

  • #3
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts
    oh.. that worked, but when the user is done with a task, the options are printed twice. DO you now hwy?

  • #4
    New Coder
    Join Date
    Dec 2002
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    make sure you're not calling the function again (recursing) at the end of the function, or after the do-while loop.. without seeing the code i can't really tell.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •