The abort () function in C

The abort () function stops executing the program abnormally.

The abort () function stops executing the program abnormally.

Declaring the abort () function in C

Below is the declaration for abort () in C:

 void abort ( void ) 

Parameters

This function does not take any parameters.

Returns the value

This function does not return any values.

For example

The following C program illustrates the usage of abort () in C:

 #include #include int main () { FILE * fp ; printf ( "Chuan bi mo laptrinhc.txtn" ); fp = fopen ( "laptrinhc.txt" , "r" ); if ( fp == NULL ) { printf ( "Dung chuong trinh !!!n" ); abort (); } printf ( "Dong laptrinhc.txtn" ); fclose ( fp ); return ( 0 ); } 

Compiling the above C program will result:

The abort () function in C Picture 1The abort () function in C Picture 1

According to Tutorialspoint

Previous lesson: Function realloc () in C

Next lesson: The function atexit () in C

5 ★ | 1 Vote