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
Discover more
parameters in C the value of C the pointer in C the elements in CShare by
Lesley Montoya
Update 25 May 2019
You should read it
- The exit () function in C
- System () function in C
- The abort () function in C
- Call the function by pointer in C ++
- Function realloc () in C
- The Quiet Details That Make a Sports Betting Platform Feel Reliable
- Instructions on creating toy set images with ChatGPT AI
- How are AI agents changing the journalism industry?
- The exit () function in C
- Remove () function in C
- Rename () function in C