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

Related questions

2 answers 261 views
1 answer 200 views
2 answers 240 views
1 answer 113 views
1 answer 166 views
166 views asked Apr 5, 2024 by avibootz
1 answer 165 views
...