switch menu, keep the program running?

Sep 28, 2011 at 2:22am
-- removed since resolved
Last edited on Sep 29, 2011 at 2:27am
Sep 28, 2011 at 2:31am
Switch-case statements are not do-while loops. That while loop at the end of your program is what stops the code in its tracks. Though, you could easily make it into a do-while loop, which is probably what you wanted.
Last edited on Sep 28, 2011 at 2:32am
Sep 28, 2011 at 2:34am
Declare the data you don't wanna lose outside main() and then at the end of de main function call main function again!
Sep 28, 2011 at 2:40am
naderST wrote:
Declare the data you don't wanna lose outside main() and then at the end of de main function call main function again!
I highly recommend not doing this. It's bad coding practice, it wastes memory, and it clutters the global scope. Did I mention that I don't recommend doing it? ;)
Last edited on Sep 28, 2011 at 2:41am
Sep 28, 2011 at 2:42am
L B wrote:
I highly recommend not doing this.


Why? well, he can write a function called menu() and then call that function...
Sep 28, 2011 at 2:43am
Yes, he could do that, but for persistent data in this case is is better to use a while loop. ;)
Last edited on Sep 28, 2011 at 2:44am
Sep 28, 2011 at 2:46am
Yes, he could do that, but for persistent data is is better to use a while loop. ;)

Thanks is good to know that!
Sep 28, 2011 at 7:26am
my initial program had do while and if-else nesting for all choices, but it ended up just printing my menu again without going thru the "cases" properly then. switch goes thru them properly, but then I get stuck without a chance to work on it further... I'll try do while again later, but I'm a bit skeptic to use it :)
Sep 28, 2011 at 8:15am
ow sorry, I misunderstood, I got it working now. nesting the switch inside the do-while did the trick, thanks guys :D
Last edited on Sep 28, 2011 at 8:25am
Topic archived. No new replies allowed.