The function atexit () in C
Int atexit function (void (* func) (void)) calls function func when the program ends. You can register your end function (func function) wherever you like, but this function will be called at the end of the program.
Int atexit function (void (* func) (void)) calls function func when the program ends. You can register your end function (func function) wherever you like, but this function will be called at the end of the program.
Declare the function atexit () in C
Below is the declaration for atexit () in C:
int atexit ( void (* func )( void ))
Parameters
func : This is the function to be called at the end of the program.
Returns the value
This function returns a value of 0 if this function is successfully registered. If it fails, it returns a value other than 0.
For example
The following program C illustrates the usage of atexit () in C:
#include #include void functionA () { printf ( "Vi du mot ham functionAn" ); } int main () { /* Dang ky mot ham ket thuc chuong trinh */ atexit ( functionA ); printf ( "Bat dau chay phan chuong trinh chinh .n" ); printf ( "Thoat chuong trinh chinh .n" ); return ( 0 ); }
Compiling and running the above C program will result:
According to Tutorialspoint
Previous lesson: Abort () function in C
Next lesson: Function exit () in C
4.3 ★ | 3 Vote
You should read it
Maybe you are interested
How to turn a photo into a painting using the Generative Fill function in Photoshop
How to use the TREND function in Excel
Google Sheets Functions to Simplify Your Budget Spreadsheets
Instructions for using the TRIMRANGE function to clean up Excel tables
How to master numerical data in Google Sheets with the AVERAGE function
Don't buy headphones if they lack this important function!