home *** CD-ROM | disk | FTP | other *** search
- Path: 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
-
- 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."
-