delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/28/11:16:43

Date: Tue, 28 Oct 1997 11:15:55 -0500 (EST)
From: "Art S. Kagel" <kagel AT ns1 DOT bloomberg DOT com>
Reply-To: kagel AT ns1 DOT bloomberg DOT com
To: Jon Seanor <jseanor AT rmplc DOT net>
Cc: djgpp AT delorie DOT com
Subject: Re: Reading the command line
In-Reply-To: <62q0ic$73f$1@panther.rmplc.co.uk>
Message-Id: <Pine.D-G.3.96.971028110954.11904C-100000@dg1>
Mime-Version: 1.0

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.

Check the news archives for the specific references to K&R and the C
standard.

Art S. Kagel, kagel AT bloomberg DOT com

- Raw text -


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