O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Standard Library: stdlib.h

Often seen as a collection point for all the miscellaneous functionality that seems to fit nowhere else, the stdlib contains many interesting features for a variety of applications.

You previously used the return keyword in the main function to leave the program itself; however, stdlib also offers some additional exit handling that extends this behavior. The first, atexit, is defined as:

atexit ( <function> )          execute function on exit

This function allows you to specify up to 32 functions (in separate calls to atexit) to execute when the program terminates normally. These functions cannot accept any parameters and will be executed in the reverse order to which they were set up by repeated calls to the atexit function. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required