what is the purpose of atexit function?

后端 未结 3 916
迷失自我
迷失自我 2021-01-21 01:13

I know when the address of the function is passed to atexit function,
the function is excuted.

#include 
int atexit(void (*fun         


        
3条回答
  •  孤城傲影
    2021-01-21 01:50

    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.

提交回复
热议问题