These are two names for the same function that does the same.
Please note, however, that in C ++ std::exit/ exit(no matter how you use it) there is some behavior that is not specified for exitin the C library. In particular,
exit first destroys all objects with a storage duration of threads that are associated with the current thread.- , ,
atexit, . - :
- C , , .
- ,
tmpfile. - , ,
exit (0 EXIT_SUCCESS = > , EXIT_FAILURE = > , - ).
, .
, exit/std::exit ++. , -, , C- , , , , - . ++, , exit, , , .
, exit, - :
struct my_exit : public std::exception {
int value;
my_exit(int value) : value(value) {}
};
int main() {
try {
}
catch(my_exit const &e) {
return e.value;
}
}
, exit, throw my_exit(whatever_value);. , (.. ), .