Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>atexit() register exit function</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 atexit()                Register Exit Function

 #include   <stdlib.h>

 int        atexit(func);
 atexit_t   func;                        Function to be called

    atexit() identifies a function as an "exit function."  The function
    is pointed to by 'func', and 'func' is a pointer of type 'atexit_t'
    (defined in <stdlib.h>).

    Up to 32 exit functions can be registered. Each requires a separate
    call to atexit(). If the program terminates normally, exit() calls
    'func' just before returning control to the operating system, and the
    exit functions are carried out on a last in, first out basis.

    Returns:    0, if successful.  If there is no remaining space for
                registering functions, a non-zero value is returned.


   -------------------------------- Example ---------------------------------

           #include <stdlib.h>

           void goodbye()
           {
               printf("Goodbye ");
           }

           void world()
           {
               printf("world!");
           }

           main()
           {
               atexit(world);
               atexit(goodbye);
               printf("Hello world.\n");
           }


See Also: exec...() exit() spawn...()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson