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
You should read it
Maybe you are interested
Discovered mysterious signals emanating from a star right next to the Solar System, possibly of aliens NASA reveals its latest snapshot of the Martian surface with a resolution of 1.8 billion pixels Found the second planet of Proxima Centauri, the star closest to the sun 7 most modern astronaut ships on the planet Is Proxima b our 'neighbor' planet? Why have scientists found Proxima b - '2nd Earth' until now?