Force Shutdown

Hello again!

Brief information about my code:
I use several void functions, which are called from the main function when so requested by the user (using switch statement for this). However, I have looped (using a for loop) the "Main Menu" so the user can do multiple things without restarting the code each time. However, there is a "Logout" option, and I want it to force shutdown the program. Currently, if I use return, the code will go back to the for loop, and wont really stop the program until it has looped 10 times.

My goal is to make it loop over and over again, until the user does this "force shutdown", but I'd like to figure out how to do that by myself, but I need help with the syntax to force a shutdown.

Thanks in advance!
Sincerely,
Jocke
Hello shadowCODE,

I already read that post but to me, it was basically arguments of which statement syntax should be used.

However, I found a way that is working to me. I made a switch case in the main function, and if the "Logout" is triggered from the void function, the switch case in main will trigger return 0;

The problem before, was that I can't have return 0; in a void function, but now it's in main.
Thanks anyway, I really appreciate your attempt to help me.

Sincerely,
Jocke
No. The post there has just what you need. See,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <cstdlib>
using namespace std;

void quit()
{
    exit(0);
}
int main()
{
    quit();
    cout<<"does not reach here";
    return 0;
}
Topic archived. No new replies allowed.