abort -- Stop a Program

Format

#include <stdlib.h>
void abort(void);

Language Level: ANSI, POSIX, XPG4, Extension
abort causes an abnormal program termination and returns control to the host environment. It is similar to exit, except that abort does not flush buffers and close open files before ending the program.

Return Value
There is no return value.

Example
This example tests for successful opening of file myfile.mjq or mylib/myfile. If an error occurs, an error message is printed and the program ends with a call to abort.

#include <stdio.h>
#include <stdlib.h>
#define FILENAME "myfile.mjq"
int main(void)
{
   FILE *stream;
   if ((stream = fopen(FILENAME, "r")) == NULL){
      perror("Could not open data file");
      abort();
   }
   return 0;
   /*******************************************************
      If requested file doesn't exist,
      the output should be:
      Could not open data file: The file cannot be found.
   *******************************************************/
}


exit -- End Program
_exit -- End Process
signal -- Handle Interrupt Signals
<stdlib.h>