##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# abort

From cppreference.com
< c‎ | program

Defined in header `<stdlib.h>` |  |
void abort(); |  |

Causes abnormal program termination unless SIGABRT is being caught by a signal handler passed to signal and the handler does not return.

Functions passed to atexit() are not called. Whether open resources such as files are closed is implementation defined. Implementation defined status is returned to the host environment that indicates unsuccessful execution.

### [edit] Parameters

(none)

### [edit] Return value

(none)

### [edit] Example

Run this code

    #include <stdio.h>      /* FILE, fopen, fclose, fprintf */
    #include <stdlib.h>     /* abort */

    int main()
    {

        FILE *fp;
        fp = fopen("data.txt","r");
        if (fp == NULL) {
           fprintf(stderr, "error opening file data.txt in function main()\n");
           abort();
        }

        /* Normal processing continues here. */
        fclose(fp);
        printf("Normal Return\n");
        return 0;
    }

Output:

    error opening file data.txt in function main()

### [edit] See also

exit | causes normal program termination with cleaning up (function) [edit]
atexit | registers a function to be called on exit() invocation (function) [edit]
quick_exit (C99) | causes normal program termination without completely cleaning up (function) [edit]
C++ documentation for abort

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/program/abort&oldid=67200"