
- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <float.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdarg.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <time.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C library function - abort()
Description
The C library function void abort(void) abort the program execution and comes out directly from the place of the call.
Declaration
Following is the declaration for abort() function.
void abort(void)
Parameters
NA
Return Value
This function does not return any value.
Example
The following example shows the usage of abort() function.
#include <stdio.h> #include <stdlib.h> int main () { FILE *fp; printf("Going to open nofile.txt\n"); fp = fopen( "nofile.txt","r" ); if(fp == NULL) { printf("Going to abort the program\n"); abort(); } printf("Going to close nofile.txt\n"); fclose(fp); return(0); }
Let us compile and run the above program that will produce the following result when it tries to open nofile.txt file, which does not exist −
Going to open nofile.txt Going to abort the program Aborted (core dumped)
stdlib_h.htm
Advertisements