atexit

Registers a function that is called without arguments at program termination.

Format

#include  <stdlib.h>

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

Argument

func
A pointer to the function to be registered.

Return Values
Indicates that the registration has succeeded. 
nonzero  Indicates failure. 

Restriction

The longjmp function cannot be executed from within the handler, because the destination address of the longjmp no longer exists.

Example

    #include <stdlib.h>
    #include <stdio.h>
    
    static void hw(void);
    
    main()
    {
        atexit(hw);
    }
    
    static void hw()
    {
            puts("Hello, world\n");
    }
    

    Running this example produces the following output:

    Hello, world
    


Previous Page | Next Page | Table of Contents | Index