Compartilhar via


return Statement in Program Termination (C++)

Issuing a return statement from main is functionally equivalent to calling the exit function. Consider the following example:

// return_statement.cpp
#include <stdlib.h>
int main()
{
    exit( 3 );
    return 3;
}

The exit and return statements in the preceding example are functionally identical. However, C++ requires that functions that have return types other than void return a value. The return statement allows you to return a value from main.

See Also

Reference

Program Termination