Back to questionsWhat exit code does
JuniorTheoryCommon
What exit code does main return in this program?
#include <iostream>
int main() {
std::cout << "Hi\n";
}0
- Expecting a random value: flowing off the end of any other value-returning function is undefined behavior, but
mainalone returns0. - Expecting a compile error: of all functions that return a value, only
mainmay end withoutreturn.
- What happens when another function returning
intreaches its closing brace withoutreturn? - What do the
<cstdlib>macrosEXIT_SUCCESSandEXIT_FAILUREmean as exit codes?