home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16080 < prev    next >
Encoding:
Internet Message Format  |  1992-11-07  |  1.3 KB

  1. Path: sparky!uunet!gatech!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!news.funet.fi!hydra!klaava!wirzeniu
  2. From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to use 'return' in c?
  5. Message-ID: <1992Nov6.144715.28006@klaava.Helsinki.FI>
  6. Date: 6 Nov 92 14:47:15 GMT
  7. References: <1992Oct29.025437.9289@nuscc.nus.sg> <1992Nov2.203701.162@ipact.com> <1992Nov4.231347.26999@u.washington.edu>
  8. Organization: University of Helsinki
  9. Lines: 17
  10.  
  11. With non-standard implementation there are no guarantees as to what any
  12. particular return value of main or value passed to the exit function
  13. means.  Traditionally, especially in Unix and systems mimicing Unix, the
  14. code 0 has meant success, and small positive integers have been used to
  15. show various error codes (the exact meaning of each code depending on
  16. the particular program).  Other systems may have had different
  17. conventions.  In summary, exit codes were non-portable.
  18.  
  19. The standard improves on this situation a) by specifying that 0 always
  20. means success, and b) by introducing the macros EXIT_SUCCESS and
  21. EXIT_FAILURE (in <stdlib.h>) with the obvious meaning.  Thus, using
  22. standard C you can always rely on ``exit(EXIT_SUCCESS)'' to indicate
  23. success to the operating system, and ``exit(EXIT_FAILURE)'' to indicate
  24. failure.
  25.  
  26. --
  27. Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
  28.