www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/23/08:30:23

From: dontmailme AT iname DOT com (Steamer)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Hello all. Im a new DJGPP user...
Date: Wed, 23 Aug 2000 12:14:56 GMT
Organization: always disorganized
Lines: 29
Message-ID: <39a3c011.16130541@news.freeserve.net>
References: <20000823033329 DOT 9373 DOT qmail AT web515 DOT mail DOT yahoo DOT com>
NNTP-Posting-Host: modem-191.goatfish.dialup.pol.co.uk
X-Trace: newsg2.svr.pol.co.uk 967032897 15549 62.137.17.191 (23 Aug 2000 12:14:57 GMT)
NNTP-Posting-Date: 23 Aug 2000 12:14:57 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Free Agent 1.11/32.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Chris Amos wrote:

>   return 0; // Can anyone tell me whats so special about 0? Why 0?

There are three standard return values: 0, EXIT_SUCCESS and
EXIT_FAILURE.  (You need to #include <stdlib.h> for the last two.)
0 and EXIT_SUCCESS indicate success, and EXIT_FAILURE indicates
failure of some sort.

>             // I mean, whats so special about it? Is is an exit code of
>             // some kind? Can i use any number I want or none at all?

You can't return none at all - or at least you're not supposed to.
The return type of main() is int, so you should return an int, or
who knows what will happen?  (The new C standard actually allows
you to omit the return from main() altogether, but this just results
in an implicit return 0.)

>             // How about return 69; or return; ? Would those work?

You can return other values, but their meaning is system dependent.
In DOS batch files you can test the return value using ERRORLEVEL,
and you can do something similar in Unix shell scripts.

By the way, you probably shouldn't use // comments in C if you
care about portability.  The new C standard allows it, but the
old one (which all current compilers follow) doesn't.

S.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019