Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Language%20in%20C%20Interview%20Questions%20and%20Answers

Question: How do I write code that executes certain function only at program termination?
Answer: Use atexit( ) function as shown in following program.

#include <stdlib.h>
main( )
{
int ch ;
void fun ( void ) ;
atexit ( fun ) ;
// code
}
void fun( void )
{
printf ( "nTerminate program......" ) ;
getch( ) ;
}
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook