linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan-Benedict Glaw <jbglaw@lug-owl.de>
To: linux prg <linux-c-programming@vger.kernel.org>
Subject: Re: exit(42)
Date: Fri, 24 Sep 2004 18:33:00 +0200	[thread overview]
Message-ID: <20040924163300.GO22710@lug-owl.de> (raw)
In-Reply-To: <20040924115759.6133.qmail@web52908.mail.yahoo.com>

[-- Attachment #1: Type: text/plain, Size: 1439 bytes --]

On Fri, 2004-09-24 12:57:59 +0100, Ankit Jain <ankitjain1580@yahoo.com>
wrote in message <20040924115759.6133.qmail@web52908.mail.yahoo.com>:
> well do any body know what does this mean?
> 
> exit(42)

It just leaves 42 (Illuminati!) back to the caller.

> and also when we say exit(0) or exit(1) then there is
> anyway to catch these values

Normally, you use a return value of zero to signal "Success!" and
anything else for "Something undesired happened."

> also when we return from main fn then what is the
> benfit?

exit() just here ends the program, possibly internally calling some
cleanup functions and the like. Return does only end a program IFF it
returns from the main() function.

> does it have any utilisation?

It does! Remember, exit() is "stop it here", while return is only "stop
it here, if I'm in main()."  See the difference? If, at some later time,
the whole program gets integrated into the codebase of a larger scale
program, where the former main() call just does one part of the work,
exit() from the old main() wouldn't be a nice thing:-)

MfG, JBG

-- 
Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
 fuer einen Freien Staat voll Freier Bürger" | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2004-09-24 16:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-24 11:57 exit(42) Ankit Jain
2004-09-24 12:13 ` exit(42) Alphex Kaanoken
2004-09-24 12:25 ` exit(42) Ron Michael Khu
2004-09-27  9:16   ` exit(42) Pankaj
2004-09-27 12:39     ` exit(42) Micha Feigin
2004-09-27 13:54       ` exit(42) Jon Masters
2004-09-24 12:29 ` exit(42) Luciano Moreira - igLnx
2004-09-24 16:33 ` Jan-Benedict Glaw [this message]
2004-09-25  1:13 ` exit(42) Micha Feigin
2004-09-25 10:57   ` exit(42) rinku rathore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040924163300.GO22710@lug-owl.de \
    --to=jbglaw@lug-owl.de \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).