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

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!marlin.jcu.edu.au!coral.cs.jcu.edu.au!spuler
  3. From: spuler@coral.cs.jcu.edu.au (David Spuler)
  4. Subject: declaration of main
  5. Message-ID: <spuler.715480577@coral.cs.jcu.edu.au>
  6. Sender: news@marlin.jcu.edu.au (USENET News System)
  7. Organization: James Cook University
  8. Date:  3 Sep 92 00:36:17 GMT
  9. Lines: 25
  10.  
  11.  
  12. A discussion of declaring main as returning void in comp.lang.c lead me
  13. to read 5.1.2.2.1 "Program startup" in my ISO standard.  According to this
  14. section, main can be declared as:
  15.  
  16. int main(void) { ... }
  17. int main(int argc, char *argv[]) { ... }
  18.  
  19. Are the following also legal, although not explicitly mentioned?
  20.  
  21. int main()  { /* non-proto declaration */ }
  22. main()  { /* non-proto declaration */ }
  23. main(void) { /* implicit int */ ... }
  24. int main(int argc, char **argv) { /* char **argv;  not char *argv[] ... }
  25.  
  26. Yes, I realize this sounds like a dumb question, but the standard doesn't
  27. seem very precise. It implies that only the first 2 are legal.
  28.  
  29. Regards,
  30. David Spuler
  31. --
  32. David Spuler, James Cook University of North Queensland, Australia
  33. Author of "Comprehensive C", Prentice-Hall, 1992, pp416, ISBN  0-13-156514-1
  34. INTRO TOPICS: types, operators, structures, strings, fns, ptrs, files etc etc
  35. ADVANCED TOPICS: efficiency, debugging, style, portability, large programs
  36.