◄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 " ); } -♦-