Top

Discussion

What is the problem with following code?

#include
int main()
{
    int *p = (int *)malloc(sizeof(int));
 
    p = NULL;
 
    free(p);
}

 

  • A.Compiler Error: free can't be applied on NULL pointer
  • B.Memory Leak
  • C.Dangling Pointer
  • D.The program may crash as free() is called for NULL pointer

Answer: B

No answer description available for this question.

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

Post your comment