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►
────────────────────────────────────────────────────────────────────────────
/* 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 " );
}