please help me.
in a program related to datahandling;
if(! fin)
{
cout%26lt;%26lt;"sorry, can't open";
exit(-1) // what does this statement do?
}
what does tha -1 inside the paranthesis refer to?
C++ exit() function.?
Exit (0), Normal end,
Exit (1) / exit (-1) Abnormal end, 1 or -1 that's personal habits,. but under normal circumstances should be used
EXIT_SUCCESS said normal EXIT_FAILURE said the failure of the definition of stdio.h Lane.
Reply:Exit codes are a number between 0 and 256, which is returned by any Unix command when it returns control to its parent process.
Other numbers can be used, but these are treated modulo 256, so exit -10 is equivalent to exit 246, and exit 257 is equivalent to exit 1.
These can be used within a shell script to change the flow of execution depending on the success or failure of commands executed. This was briefly introduced in Variables - Part II. Here we shall look in more detail in the available interpretations of exit codes.
Success is traditionally represented with exit 0; failure is normally indicated with a non-zero exit-code. This value can indicate different reasons for failure.
For example, GNU grep returns 0 on success, 1 if no matches were found, and 2 for other errors (syntax errors, nonexistant input files, etc).
Reply:Well if SDL or POGL are in there thats the exit command. Only reason I can think of for the -1 is to force it to signed.
Reply:void exit ( int status ); %26lt;cstdlib%26gt;
Terminate calling process
Terminates the process normally, performing the regular cleanup for terminating processes.
First, all functions registered by calls to atexit are executed in the reverse order of their registration. Then, all streams are closed and the temporary files deleted, and finally the control is returned to the host environment.
The status argument is returned to the host environment.
Parameters
status
Status value returned to the parent process. Generally, a return value of 0 or EXIT_SUCCESS indicates success, and any other value or the constant EXIT_FAILURE is used to indicate an error or some kind of abnormal program termination.
Returns: None
Reply:i m not sure...bt as far as i remember..... it's something related to normal or abnormal exit.........
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment