abort
void  abort ( void );
stdlib.h
  cplusplus.com  

Abort current process returning error code.
  Prints the message "Abnormal termination program", and immediately after aborts the process returning an error code (by default is 3). It does not flush any open stream and do not evaluate any atexit function.

Parameters.

(none)

Return Value.
  None.
  The calling process does not receives back control. abort returns the error code 3 to the parent process or the OS.

Portability.
  Defined in ANSI-C.

Example.

/* abort example */
#include <stdio.h>
#include <stdlib.h>

main()
{
  FILE * pFile;
  pFile= fopen ("myfile.txt","r");
  if (pFile == NULL) 
  {
    printf ("error opening file\n");
    abort();
  }

  /* normal file manipulation here */

  fclose (pFile);
  return 0;
}
  If myfile.txt doesn't exist a message is printed, abort is called and the errorlevel returned would be 3. Otherwise the file is normally closed and the errorlevel returned is 0 (return 0).

See also.
  exit, atexit, signal


© The C++ Resources Network, 2000