In C and C++, function main can return an integer value. You can use this value to hold the return code from your program.Typically, you return a non-zero value to indicate the program is unable to continue, or a 0 upon normal termination. You can use different values to represent different errors or other conditions.
To make main return a specific value to the operating system, use the return statement or call the exit function and specify the value to be returned. For example, the following program returns the value 6 to the operating system.
int main() {
// do nothing but set the return code to 6
return 6;
}
If you do not specify a return value in C, the return
code of your program is undefined.
If you do not specify a return value in C++, your
program returns a value of zero.
VisualAge C++ provides much more flexible and powerful methods that you can use to deal with exceptional circumstances that can occur during program execution, including signal and exception handling.
![]()
Signals
and Exceptions
Signal
and Exception Handling
![]()
Run Your Application
Get the Return Code
of an Application
![]()
C
Structured Exception Handling
