Abort() - C library function Program
Declaration :
void abort(void)
Explanation :
Purpose | The C library function void abort(void) abort the program execution and comes out directly from the place of the call. |
Parameters | NA |
Return Value | This function does not return any value. |
Header File | stdlib.h |
Exception |
C Program : Example
The following example shows the usage of abort() function.
#include<stdio.h> #include<stdlib.h> int main () { FILE *fp; printf("Open non-existing file in read mode"); fp = fopen( "invisible.txt","r" ); if(fp == NULL) { printf("File does not exists\n"); abort(); } printf("Close the file\n"); fclose(fp); return(0); }
In this case we don’t have invisible.txt file present in the directory so when we compile the above program then output of the program will be like this -
Open non-existing file in read mode File does not exists