www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/17/22:31:02

Date: Thu, 18 Jul 1996 10:29:39 +0800 (GMT)
From: Orlando Andico <orly AT gibson DOT eee DOT upd DOT edu DOT ph>
To: Nissim Chudnoff <nchudnof AT binx DOT mbhs DOT edu>
cc: DJGPP Questions <djgpp AT delorie DOT com>
Subject: Re: int main()
In-Reply-To: <Pine.LNX.3.93.960716092750.7208A-100000@binx.mbhs.edu>
Message-ID: <Pine.SGI.3.93.960718102837.21991B-100000@gibson.eee.upd.edu.ph>
MIME-Version: 1.0

On Tue, 16 Jul 1996, Nissim Chudnoff wrote:

> A while ago, there was a conversation about 'void main()' vs. 'int main()'
> and I wondered if:
> 
> void main()
> {
>    exit(1);
> }
> 
> Is the same as
> 
> int main()
> {
>    return(1);
> }


No it's not. The first method (at least, when I tested it under Linux)
would return a random, nonzero (but small magnitude) positive integer,
i.e. 2. This is normally used to signal an error condition so it's a bad
idea to declare void main().

--
Orlando Andico                           http://gibson.eee.upd.edu.ph/~orly/
orly AT gibson DOT eee DOT upd DOT edu DOT ph                "Who knows what's going to happen,
IRC Lab/EE Dept/UP Diliman     lottery or car crash, or you'll join a cult."


- Raw text -


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