in C, main()
function always has to return an int
.
That int
value is returned to the operating system to indicate how did the program exit (successful termination, error during run) etc ....
In Windows, the value returned by main()
is stored in a pseudo environment variable named errorlevel
. to check for the its value you can simple use echo
.
echo the program terminated with exit code %errorlevel%
a successful run is usually indicated by the value 0
. *
that is why you see the traditional return 0;
in all C
Programs.
* As mentioned in the comment this is not a standard nor a requirement, it just the convention