How to call a function on program termination in C

1 Answer

0 votes
#include <stdio.h>
#include <stdlib.h>

void function() {
   printf("function()");
}

int main() {
   atexit(function);
   
   puts("main()");
}



/*
run:

main()
function()

*/

 



answered Feb 27, 2022 by avibootz
...