C Programming/stdlib.h/atexit

atexit (at exit) is a function that is in the C Programming Language to register the given function to be executed at normal process termination, either via exit or via return from the program's main function.

The  function takes, as argument, the reference of the function to be registered for call back. Functions so registered are called in the reverse order of their registration; no arguments are passed.

POSIX Usage
The  function is standardized by the POSIX specification.

The prototype of the function is as below:

The function returns zero (0) if it completed execution successfully. Non-zero return values signify an error.

POSIX requires that an implementation of  allow at least ATEXIT_MAX (32) such functions to be registered.

Example
The following example demonstrates the use of the  function.