Re: The difference between return and exit()?

From: Måns Rullgård (mru_at_mru.ath.cx)
Date: 09/28/04


Date: Tue, 28 Sep 2004 10:38:02 +0200

learning_c@hotmail.com (learning_C++) writes:

> Hi,
> I often see the functions like exit() and close(). Can they replace
> return in the c program? Which header includes them?
> What is the difference between exit(0), exit(1) and exit(...)?
> Please give me some examples.

exit() causes the program to exit with the argument as return value.
The return statement only returns from a function to its caller. In
main(), this amounts to exiting the program. close() is for closing
files opened with open().

Use the command "man" to view the manual for these function. Running
"man exit" will give information on the exit() function, etc.

-- 
Måns Rullgård
mru@mru.ath.cx


Relevant Pages

  • Re: Header call and exit()
    ... If making a header(location:) call, is it good practice to place an exit() statement after it, or will the header call take control of the script? ... Obviously the request is within the same ...
    (comp.lang.php)
  • Re: So lost... Need help
    ... I think I'm going to go in a different direction w/ this perl script so ... Thanks for reading. ... Name" is a header): ...
    (perl.beginners)
  • Re: Header call and exit()
    ... If making a header(location:) call, is it good practice to place an exit() statement after it, or will the header call take control of the script? ... So if the next execution is delete the current record, that is what will happen - only it doesn't happen *every* time because sometimes the execution of the new request is virtually immediate and other times it is not, depending on the speed of the connection, speed of the computer, number of connections to the server, etc, etc. ...
    (comp.lang.php)
  • Re: Header call and exit()
    ... If making a header(location:) call, is it good practice to place an exit() statement after it, or will the header call take control of the script? ... If the exitcommand is not issued, the script can still do database access, or whatever in the 'background'? ...
    (comp.lang.php)
  • Re: output buffering, parse error unexpected t_string
    ... This is the header line it conflicts with so I surrounded it with the ... I have a question is this buffer supposed to go around the whole php ...  Everytime I used it with the exit ...
    (comp.lang.php)