Top

Discussion

What will the code display on compiling?

void funccall() 
{ 
   printf("this is funccall\n"); 
}  
void main () 
{   
    atexit(funccall); 
    printf("program starts\n");  
    printf("program ends\n");  
}

 

  • A.
    program starts
    this is funccall
    program ends

  • B.
    this is funccall
    program starts
    program ends
  • C.
    program starts
    program ends
    this is funccall
  • D.error

Answer: C

int atexit(void (*func)(void)) calls the specified function func when the program terminates. we can register termination function anywhere in the program, but it will be called at the time of the program termination.

No comment is present. Be the first to comment.
Loading…

Post your comment