Stuck again!

This is a discussion on Stuck again! within the C++ Programming forums, part of the General Programming Boards category; Ok, well I got the menu set up and when the user enters a option it displays the string. Then ...

Stuck again!

Ok, well I got the menu set up and when the user enters a option it displays the string. Then I want the menu to reapear again so they may choose another option but i keep getting the press any key to continue comand.

While you're breakin' down my back n'
I been rackin' out my brain
It don't matter how we make it
'Cause it always ends the same
You can push it for more mileage
But your flaps r' wearin' thin
And I could sleep on it 'til mornin'
But this nightmare never ends
Don't forget to call my lawyers
With ridiculous demands
An you can take the pity so far
But it's more than I can stand
'Cause this couchtrip's gettin' older
Tell me how long has it been
'Cause 5 years is forever
An you haven't grown up yet
-- You Could Be Mine - Guns N' Roses

While you're breakin' down my back n'
I been rackin' out my brain
It don't matter how we make it
'Cause it always ends the same
You can push it for more mileage
But your flaps r' wearin' thin
And I could sleep on it 'til mornin'
But this nightmare never ends
Don't forget to call my lawyers
With ridiculous demands
An you can take the pity so far
But it's more than I can stand
'Cause this couchtrip's gettin' older
Tell me how long has it been
'Cause 5 years is forever
An you haven't grown up yet
-- You Could Be Mine - Guns N' Roses

However, this is not the best way to go about it. You should structure your program so that it flows logically, and when it exits it should return from the main() function. Post up what code you have now.

Using return 0; or return 1; (or any other number) inside main() will end the main function which effectively ends the program.

Also, using exit(0); or exit(1); (or any other number) anywhere in the program will end the program.

Usually 0 means success and non-zero means failure.

In your case, it would NOT make as much sense to use either of these. What would make more sense would be to break out of the while loop and let the program end on its own. Since you have code after the while loop (system("pause")), I would assume that you want that code to be called.

The way to break out of the while loop is to set continue = false; when the user selects 4. Then, the next time the while loop checks continue, it is false and so it no longer will loop. That is the more logical way of ending the program.

[Edit] - Oops, too late. You don't need the x anymore. That was just an example. What happened to the bool continue = true; code that you used for your while loop?