Is there a line in c++ that allows me to terminate my program while I am not in main()?
For example, a code where if you die you have to quit the game? I don't want it to rely on the "trust" system.
Is there a line in c++ that allows me to terminate my program while I am not in main()?
For example, a code where if you die you have to quit the game? I don't want it to rely on the "trust" system.
Is there a line in c++ that allows me to terminate my program while I am not in main()?
I would not use the word "line" here - better say "function". For normal termination, you can use std::exit()
(also see § 18.5/8 of the C++11 Standard):
#include <cstdlib>
void foo()
{
std::exit(EXIT_SUCCESS);
}
int main()
{
foo();
}
Here is a live example.