I know when the address of the function is passed to atexit
function,
the function is excuted.
#include
int atexit(void (*fun
atexit
would be used for some code that you want to execute when the application terminates, regardless of where it was exited from. One example would be an application-wide logger. You would call atexit(flush_log)
, so when the application exits, the log will be flushed, without the developer having to remember to flush it.