home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / std / c / 2560 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.5 KB  |  37 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!jit081.enet.dec.com!diamond
  2. From: diamond@jit081.enet.dec.com (03-Sep-1992 1314)
  3. Newsgroups: comp.std.c
  4. Subject: Re: declaration of main
  5. Message-ID: <9209030415.AA23860@enet-gw.pa.dec.com>
  6. Date: 3 Sep 92 04:15:42 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Lines: 27
  9.  
  10. In article <spuler.715480577@coral.cs.jcu.edu.au> spuler@coral.cs.jcu.edu.au (David Spuler) writes:
  11. >5.1.2.2.1 "Program startup" [...] main can be declared as:
  12. >  int main(void) { ... }
  13. >  int main(int argc, char *argv[]) { ... }
  14. >Are the following also legal, although not explicitly mentioned?
  15. >  int main()  { /* non-proto declaration */ }
  16.  
  17. That one automatically gets a prototype of int main(void).  No problem.
  18.  
  19. >  main()  { /* non-proto declaration */ }
  20.  
  21. The default return type for C functions has been int since 1970, and was not
  22. changed by the standard.  It gets the same prototype as above.  No problem.
  23.  
  24. >  main(void) { /* implicit int */ ... }
  25.  
  26. The default return type hasn't changed during the last three seconds  :-)
  27.  
  28. >  int main(int argc, char **argv) { /* char **argv;  not char *argv[] ... }
  29.  
  30. In int main(int argc, char *argv[]), the type of the second parameter is
  31. automatically adjusted (by the standard) to yield exactly what you have
  32. typed here.  I think you're allowed to save that step  :-)
  33. --
  34. Norman Diamond       diamond@jit081.enet.dec.com
  35. If this were the company's opinion, I wouldn't be allowed to post it.
  36. "Yeah -- bad wiring.  That was probably it.  Very bad."
  37.