Message-Id: <3.0.16.19971029005208.1b97170c@hem1.passagen.se> Date: Wed, 29 Oct 1997 01:01:26 -0500 To: kagel AT ns1 DOT bloomberg DOT com From: Peter Palotas Subject: Re: Reading the command line Cc: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Precedence: bulk At 11.15 1997-10-28 -0500, you wrote: >On Fri, 24 Oct 1997, Jon Seanor wrote: > >> >And the return type of main is int, not void. That should be in any text >> >book too. >> >> >> Only if you want to return something! > >WRONG! WRONG! WRONG! WRONG! WRONG! WRONG! WRONG! WRONG! WRONG! WRONG! > >Function main() MUST ALWAYS RETURN INT and MUST ALWAYS END WITH A RETURN >statement! The startup code will be returning the value at the top of the >stack whether you like it or not, this is required by C convention, the C >standard, and most modern operating systems. If you do not want to return >anything useful return zero(0), but you must return something or the OS >status code (ERRORLEVEL in DOS) for the task will be garbage. Howcome this is such a debated issue? Let the people who doesn't want to return anything do so if that makes them happy. A program will compile anyway, even if main isn't declared to return an int, possibly with a warning, but sometimes not even that (depending on what compiler you use). Personally I always declare main to return an integer since this is the right thing to do, but it isn't neccessary as far as I can see, if you don't want to return anything from main(). -- Peter Palotas alias Blizzar -- blizzar AT hem1 DOT passagen DOT se -- ***************************************************** * A brief description of DJGPP: * * NEVER BEFORE HAS SO FEW DONE SO MUCH FOR SO MANY! * *****************************************************