Thread: return from main

  1. #1
    Unregistered
    Guest

    return from main

    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.

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    27
    Hi,
    The return from main() running under DOS can be accessed in DOS using "errorlevel" and used with "if" in a DOS bat file.

    myprog.exe
    if errorlevel 4 goto four
    if errorlevel 3 goto three
    and so on

    goto exit

    :four
    echo In four
    goto exit

    :three
    echo In three
    goto exit

    and so on

    :exit

    Note that DOS will 'goto' on any errorlevel larger than the one given so the errorlevels should be checked in desending order.
    Pappy
    You learn something new everyday.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to combine these working parts??
    By transgalactic2 in forum C Programming
    Replies: 0
    Last Post: 02-01-2009, 08:19 AM
  2. Another weird error
    By rwmarsh in forum Game Programming
    Replies: 4
    Last Post: 09-24-2006, 10:00 PM
  3. DirectInput help
    By Muphin in forum Game Programming
    Replies: 2
    Last Post: 09-10-2005, 11:52 AM
  4. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  5. Algorithm to walk through a maze.
    By Nutshell in forum C Programming
    Replies: 30
    Last Post: 01-21-2002, 01:54 AM