so exit(); should return to the end of program.
but what num shoud i return inside of the exit();???
so exit(); should return to the end of program.
but what num shoud i return inside of the exit();???
>but what num shoud i return inside of the exit();???
You can return anything that the calling process accepts, but the three portable values are 0, EXIT_SUCCESS, and EXIT_FAILURE.
-Prelude
My best code is written with the delete key.
but why did most of the reference books shown ..
exit (100);
and then at the end of the prog shown exit (100);
so what's the meaning stand for? no meaning anyway ??
Many people seem to think that you can return any value as long as it's a valid int, they're wrong.
-Prelude
My best code is written with the delete key.
I have seen in several source code that when testing for an error exit(1) is used. Does this substitute for EXIT_FAILURE?
Straight out of stdlib.h
Code:#define EXIT_FAILURE 1
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
What i have guessed from it.. that numbers other then 0 passed back to the environment..used for error detection by the environment..??? .. what i have read in many books that exit(0) is simply for exit with success and exit(1) for error...
Every other number is passed back to the environment 'as is', and how the environment treats that number is implementation specific.
Is this function have different meanings with same output for different O/S's ??????
One day you will ask what more important to you..
I will say my life..
and You will leave me with even knowing
that
You are my Life (L)
if something goes wrong: exit(EXIT_FAILURE) or exit(1), if there is no problem exit(EXIT_SUCCESS) or exit(0)
Wat is the meaning of 1 and 0? It's define by the programmer.
So, if the programmer write #define SUCCESS 1, the 1 represents success, if u returns 0 (not 1) so in any way this is not considered success. My conclusion is: Just use the EXIT_SUCCESS and the EXIT_FAILURE. They really represents their meanings.
Life is difficult...
This doesn't make any sense. Sure for your personal use you may consider whatever value you define as success, success, but the OS won't be seeing eye to eye with you.Originally posted by FCF
Wat is the meaning of 1 and 0? It's define by the programmer.
So, if the programmer write #define SUCCESS 1, the 1 represents success, if u returns 0 (not 1) so in any way this is not considered success.
Just because you create some macro named "SUCCESS", this doesn't mean that the OS or anyone else reading your program will treat it as the same. What you define as success or failure is really irrelevant.
Other than the assigned values, anything else is as it's already been described: unspecified. The OS can do whatever it feels like with it.
Quzah.
Hope is the first step on the road to disappointment.