c++ - How to close a program while not in main -
this question has answer here:
- how make c++ console program exit? 11 answers
- how can close program in c? 4 answers
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
Post a Comment