totn C Functions

C Language: atexit function
(Register Function to be Called at Program Exit)

In the C Programming Language, the atexit function registers a function as a termination function which is called if the program terminates normally.

When calling the atexit function more than once, the last function to be registered is the first function that will be called when the program is terminated normally.

Syntax

The syntax for the atexit function in the C Language is:

int atexit(void (*func)(void));

Parameters or Arguments

func
The function to register as a termination function.

Returns

The atexit function returns zero if successful and a nonzero value if unsuccessful.

Required Header

In the C Language, the required header for the atexit function is:

#include <stdlib.h>

Applies To

In the C Language, the atexit function can be used in the following versions:

  • ANSI/ISO 9899-1990

Similar Functions

Other C functions that are similar to the atexit function:

See Also

Other C functions that are noteworthy when dealing with the atexit function: