1.5) Your First C++ Program: Returning A Value From main
The int
part of int main()
means that the main
function returns an int
(integer) value to its caller - which, in this case, is the operating system environment that invoked the program.
This returned value is the program exit status. By convention, an exit status of 0 means that the program ran successfully; non-zero values can be used to indicate error of different kinds
Program exit status is available for use by an operating system shell:
- In the Linux bash shell, it is stored in the shell variable
$?
- In the Windows command shell, it is stored in the variable
errorlevel