We often write large and complex programs. We allocate memory, open files/ resources and lots of other things. Most of the time our program executes in proper environment and encounters less/no error. We should handle this errors and exit properly.
Exiting from a logic or program involves freeing up memories and closing handles and files. We often write a cleanup handler which does this work. once cleanup is done we can exit gracefully. This cleanup ensures no memory and resource leak.
C runtime provides a atexit() API to register for cleanup handlers.
int atexit(void (*function)(void));
User need to implement these callbacks and C runtime will call all registered callbacks in reversed order. Maximum 32 routines can be registered for one application.
About our authors: Team EQA
You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Free alt softwares