View Full Version : return from main

01-11-2002, 07:16 AM
dos prog on windows95 machine

A return value of 0 from main signals all is fine any other value indicates some sort of error but where do these returns from main go to I know they go to the operating system but where and why because my program/compiler will indicate any errors if there are any.

thanks for the help.
learner wanting to be a master.

01-11-2002, 10:04 AM
The return from main() running under DOS can be accessed in DOS using "errorlevel" and used with "if" in a DOS bat file.

if errorlevel 4 goto four
if errorlevel 3 goto three
and so on

goto exit

echo In four
goto exit

echo In three
goto exit

and so on


Note that DOS will 'goto' on any errorlevel larger than the one given so the errorlevels should be checked in desending order.