Re: the mystery of <ctrl-d>



Bill Pursell said:
Keith Thompson wrote:
Bill Pursell writes:
chandanlinster wrote:

exit(EXIT_SUCCESS);

It seems weird to exit() here instead of simply returning a
value...

[...]

Why? Within the main() function, "exit(EXIT_SUCCESS)': and
"return EXIT_SUCCESS;" are (almost) exactly equivalent.

Just because it seems odd. It seems cleaner to return
than to exit, but there's no reason for that other than
aesthetics.

Al Balmer already pointed out that a good compiler will diagnose the
absence of a return statement from a function declared as returning a
value.

exit() feels like something that should be
reserved for an error condition.

I wouldn't dream of using it for that purpose. That's what:

return EXIT_FAILURE;

is for. In fact, I can't think of any use whatsoever for exit().

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.



Relevant Pages

  • Re: the mystery of
    ... Just because it seems odd. ... It seems cleaner to return ... than to exit, but there's no reason for that other than ...
    (comp.lang.c)
  • Re: the mystery of
    ... Just because it seems odd. ... It seems cleaner to return ... than to exit, but there's no reason for that other than ... There is one reason. ...
    (comp.lang.c)
  • Re: Comments are welcome for two sequential search C functions
    ... Bill Pursell wrote: ... exit point", but I think it's acceptable, and cleaner than ... a team leader who had imposed that rule rigorously, ...
    (comp.lang.c)
  • Re: the mystery of
    ... Just because it seems odd. ... It seems cleaner to return ... than to exit, but there's no reason for that other than ...
    (comp.lang.c)
  • Re: Image identification needed
    ... Does that part of Canada use rectangular exit gore signs? ... Or do they use the odd shaped rhombus ones like are used in the western Canada? ... I do seem to remember they had rectangle/square signs not some 'odd' shaped animal. ...
    (misc.transport.road)