Syntax
#include <stdlib.h> void abort(void);Description
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. Calls to abort raise the SIGABRT signal.
There is no return value.
This example tests for successful opening of the file MYFILE.MJQ. If an error occurs, an error message is printed and the program ends with a call to abort.
#include <stdio.h> #include <stdlib.h> int main(void) { FILE *stream; if (NULL == (stream = fopen("myfile.mjq", "r"))) { perror("Could not open data file"); abort(); } return 0; /**************************************************************************** If myfile.mjq does'nt exist, the output should be: Could not open data file: The file cannot be found. ****************************************************************************/ }Related Information