Unix Programming - The difference between return and exit()?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > September 2004 > The difference between return and exit()?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author The difference between return and exit()?
learning_C++

2004-09-28, 3:32 am

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.

Thanks,
Måns Rullgård

2004-09-28, 3:32 am

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
Alex Vinokur

2004-09-28, 8:28 am


"learning_C++" <learning_c@hotmail.com> wrote in message news:44bd0859.0409280026.16dfcd53@posting.google.com...
> 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.
>
> Thanks,


The difference between return, exit() and abort() in C++ program can be seen at
http://groups.google.com/groups?sel...p1.dejanews.com

--
Alex Vinokur
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com