Examveda

The following C code is an example of . . . . . . . .
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
main()
{
    char *p,*q;
    p=(char*)malloc(3*sizeof(char));
    q=p;
    strcpy(p,"hello");
    printf("p=%s",p);
    printf("q=%s",q);
    free(q);
    q=NULL;
    gets(p);
    gets(q);
    printf("%s",p);
    printf(“%s”,q);
}

A. Memory leak

B. Dangling pointer

C. Static memory allocation

D. Linked list

Answer: Option B


This Question Belongs to C Program >> Memory Allocation

Join The Discussion

Related Questions on Memory Allocation