C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
ATEXIT.C
                                             Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
/* ATEXIT.C illustrates function:
 *      atexit          _onexit
 */
 
#include <stdlib.h>
#include <stdio.h>
#define ANSI                /* Comment out to try _onexit     */
 
/* Prototypes */
void fn1( void ), fn2( void ), fn3( void ), fn4( void );
 
void main()
{
 
    /* atexit is the ANSI standard. It returns 0 for success, nonzero
     * for fail.
     */
#if defined( ANSI )
    atexit( fn1 );
    atexit( fn2 );
    atexit( fn3 );
    atexit( fn4 );
 
    /* _onexit is a Microsoft extension. It returns a pointer to a function
     * for success, NULL for fail.
     */
#else
    _onexit( fn1 );
    _onexit( fn2 );
    _onexit( fn3 );
    _onexit( fn4 );
#endif
 
    printf( "This is executed first.\n" );
}
 
void fn1()
{
    printf( "next.\n" );
}
 
void fn2()
{
    printf( "executed " );
}
 
void fn3()
{
    printf( "is " );
}
 
void fn4()
{
    printf( "This " );
}
                                    -♦-