c++ - How to close a program while not in main -


this question has answer here:

is there line in c++ allows me terminate program while not in main()?

for example, code if die have quit game? don't want rely on "trust" system.

is there line in c++ allows me terminate program while not in main()?

i not use word "line" here - better "function". normal termination, can use std::exit() (also see § 18.5/8 of c++11 standard):

#include <cstdlib>  void foo() {     std::exit(exit_success); }  int main() {     foo(); } 

here live example.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -