void abort (void);
[[noreturn]] void abort() noexcept;
raise(SIGABRT) was called). This, if uncaught, causes the program to terminate returning a platform-dependent unsuccessful termination error code to the host environment.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* abort example */
#include <stdio.h> /* fopen, fputs, fclose, stderr */
#include <stdlib.h> /* abort, NULL */
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;
}