delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/20/02:37:51

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: New C Programmer Problem
Date: Thu, 19 Dec 1996 22:48:49 -0800
Organization: Alcyone Systems
Lines: 34
Message-ID: <32BA36D1.31273C98@alcyone.com>
References: <32B9BAC8 DOT 5C26 AT bc DOT cybernex DOT net> <19961220 DOT 163011 DOT 8335 DOT 2 DOT chambersb AT juno DOT com>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Benjamin D Chambers wrote:

> >My program is:
> >#include <stdio.h>
> >main()
> >{
> >  printf("whatever");
> >}
> >
> Not to be nit-picky (okay, I'm nit-picking) but I believe there are only
> two ANSI defined ways to declare main.  The one you probably wanted to
> use was
> int main(void)
> {
>  ...your commands...
>  return(0);  ...Or whatever...
> }

Actually, the mere declaration

    main() { ... }

in fact does define main as returning int and taking no parameters.  In C,
the default return type of a function when not explicitly specified is int.
Also, when no parameters are explicitly specified, in a definition it is
taken as of taking no parameters.  (In a prototype, in C, it doesn't say
anything about the parameter list; in C++, it always means no parameters.)

-- 
                             Erik Max Francis | max AT alcyone DOT com
                              Alcyone Systems | http://www.alcyone.com/max/
                         San Jose, California | 37 20 07 N 121 53 38 W
                                 &tSftDotIotE | R^4: the 4th R is respect
     "You must surely know if man made heaven | Then man made hell"

- Raw text -


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