Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>onexit() register terminating function</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
onexit()                 Register Terminating Function

 #include   <stdlib.h>

 onexit_t   onexit(func);
 onexit_t   func;                        Pointer to function to call on exit

    onexit() registers 'func' in the list of functions to be called when
    the calling process terminates normally (either by returning from
    main() or by calling exit()).  onexit() can register up to 32
    functions, which are executed in a "last-in, first-out" order.

    Returns:    'func' if successful; NULL if 32 functions are already
                registered.

      Notes:    _exit() and abort() do not execute functions registered
                with onexit().

                The functions registered with onexit cannot have
                parameters.  Type 'onexit_t' is defined in stdlib.h.

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

    The following program prints out "good-bye".

          #include <stdlib.h>

          dash()
          {
              printf("-");
          }

          bye()
          {
              printf("bye\n");
          }

          main()
          {
              onexit(bye);
              onexit(dash);
              printf("Good");
          }

See Also: exit() _exit() abort()

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