Re: the mystery of <ctrl-d>
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Mon, 30 Apr 2007 05:39:24 +0000
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.
.
- Follow-Ups:
- Re: the mystery of <ctrl-d>
- From: Nick Keighley
- Re: the mystery of <ctrl-d>
- References:
- the mystery of <ctrl-d>
- From: chandanlinster
- Re: the mystery of <ctrl-d>
- From: Bill Pursell
- Re: the mystery of <ctrl-d>
- From: Keith Thompson
- Re: the mystery of <ctrl-d>
- From: Bill Pursell
- the mystery of <ctrl-d>
- Prev by Date: Re: Ahead of "main"?
- Next by Date: Re: Ahead of "main"?
- Previous by thread: Re: the mystery of <ctrl-d>
- Next by thread: Re: the mystery of <ctrl-d>
- Index(es):
Relevant Pages
|