abort


function
<cstdlib>
void abort ( void );

Abort current process

Aborts the process with an abnormal program termination.
The function generates the SIGABRT signal, which by default causes the program to terminate returning an unsuccessful termination error code to the host environment.

The program is terminated without executing destructors for objects of automatic or static storage duration, and without calling any atexit function.

The function never returns to its caller.

Parameters

(none)

Return Value

(none)

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* abort example */
#include <stdio.h>
#include <stdlib.h>

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

  /* regular process here */

  fclose (pFile);
  return 0;
}


If myfile.txt does not exist, a message is printed and abort is called.

See also