Mail Archives: djgpp/1997/10/28/11:16:43
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 -