C/exit

Advertisement


Question
why v r using exit(0) in some program...wat it exactly do..

Answer
I think you can very easily see a detailed information of this in a man page.
exit() is a function, which is used to exit from a program.
When you execute a program, your shell will start a process and that process is nothing but your program.
So, when your program returns, how will the shell know, whether it finished successfully or not?
So, you will pass 0 or some value to shell, so that you can use it to know the exit status.
Usually 0 is considered success.
And there can be many reasons for failure.
So, you can return many different values.
And read the exit status to know the cause of failure.

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

©2012 About.com, a part of The New York Times Company. All rights reserved.