This documentation is archived and is not being maintained.

return Statement (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.

Show: