TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Roy McNeill
from: andrew clarke
date: 1996-08-23 13:22:59
subject: return 0

18 Aug 96 13:39, Roy McNeill wrote to Peter Leschev:

 > There's a loose convention (not a rule) that says you return 0 for 
 > normal termination, and non-zero values for abnormal termination.

The C Standard says that

  int main(void)
  {
      return 0;
  }

is identical to

  #include 

  int main(void)
  {
      exit(0);
  }

and that if the value of the parameter passed to exit() is zero of
EXIT_SUCCESS, an "implementation-defined form of the status successful
termination is returned".  It continues, "If the value of [the
parameter passed to exit()] is EXIT_FAILURE, an implementation-defined form
of the status unsuccessful termination is returned.  Otherwise the status
returned is implementation defined."

So there you go - it's not just convention after all.  :-)

Regards
Andrew

-- randy{at}zws.com

--- Msged/2 4.00
* Origin: Blizzard of Ozz, Melbourne, Australia (3:635/727.4{at}fidonet)
SEEN-BY: 50/99 620/243 623/630 632/349 635/503 544 727 728 711/401 409 410
SEEN-BY: 711/413 430 808 809 932 934 712/515 713/888 714/906 800/1
@PATH: 635/727 544 50/99 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.