switch menu, keep the program running?

-- removed since resolved
Last edited on
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
Declare the data you don't wanna lose outside main() and then at the end of de main function call main function again!
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
L B wrote:
I highly recommend not doing this.


Why? well, he can write a function called menu() and then call that function...
Yes, he could do that, but for persistent data in this case is is better to use a while loop. ;)
Last edited on
Yes, he could do that, but for persistent data is is better to use a while loop. ;)

Thanks is good to know that!
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 :)
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
Topic archived. No new replies allowed.