The Return Value of main( )
This lesson explains the return value of main() and how we can specify the return value.
We'll cover the following...
We have seen that main()
is a function. Program execution starts with main()
and branches off to other functions from there. The definition of main()
that we have used so far has been the following:
void main() {
// ...
}
According to that definition main()
does not take any parameters and does not return a value. In reality, in most systems, every program necessarily returns a value to its environment when it ends, which is called an exit status or return code. Because of this, although it is possible to specify the return type of main()
as void
, it will actually return a value to the operating system or launch environment.
The return value of main()
...Access this course and 1400+ top-rated courses and projects.