Exit a Program

Hello. How do I exit a program. What is the code so that when a variable (of my choosing) is entered, The program displays a message and quits? It is probably really obvious and I probably use it everyday, but I am stupid. Any help would be appreciated. Thank you!
There are multiple ways to exit a program, some graceful, some not, but the most proper way is just to return from main.
So what would the code look like in an example?
return 0;
Thank you. But on the inside of a function, will this work to close the whole program?
For example, if I am in the middle of a function in the middle of all the code and I want the user to enter whether or not they want to make the whole program stop and quit, will this work?
No. If you have to do that, you have a design flaw, but if you can't fix the design flaw the next best thing is to use std::exit.

Topic archived. No new replies allowed.