🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1247

Re: declaration of main

#1247
From: 03-Sep-1992 1314
Date: Thu, 03 Sep 1992 04:15
27 lines
1580 bytes
In article <spuler.715480577@coral.cs.jcu.edu.au> spuler@coral.cs.jcu.edu.au (David Spuler) writes:
>5.1.2.2.1 "Program startup" [...] main can be declared as:
>  int main(void) { ... }
>  int main(int argc, char *argv[]) { ... }
>Are the following also legal, although not explicitly mentioned?
>  int main()  { /* non-proto declaration */ }

That one automatically gets a prototype of int main(void).  No problem.

>  main()  { /* non-proto declaration */ }

The default return type for C functions has been int since 1970, and was not
changed by the standard.  It gets the same prototype as above.  No problem.

>  main(void) { /* implicit int */ ... }

The default return type hasn't changed during the last three seconds  :-)

>  int main(int argc, char **argv) { /* char **argv;  not char *argv[] ... }

In int main(int argc, char *argv[]), the type of the second parameter is
automatically adjusted (by the standard) to yield exactly what you have
typed here.  I think you're allowed to save that step  :-)
--
Norman Diamond       diamond@jit081.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
"Yeah -- bad wiring.  That was probably it.  Very bad."
Technical Details
Message-ID: <9209030415.AA23860@enet-gw.pa.dec.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!jit081.enet.dec.com!diamond

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!jit081.enet.dec.com!diamond
From: diamond@jit081.enet.dec.com (03-Sep-1992 1314)
Newsgroups: comp.std.c
Subject: Re: declaration of main
Message-ID: <9209030415.AA23860@enet-gw.pa.dec.com>
Date: 3 Sep 92 04:15:42 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Lines: 27