What is Dangling Pointer?



Vikas Said

+0 -0

Dangling Pointer is a Special type of pointer in which that memory location is free or deleted.

For Example:
int main()
{
    int *p=(char*)malloc(sizeof(char));
    free(p);
    p=NULL;
    //p is the dangling Pointer
}



Suraj Said

+0 -0

A dangling pointer is a pointer in your program that points to memory that's been deleted.



Ayush Said

+0 -0

A dangling pointer is a pointer in C programming that points to memory that has been deallocated (freed) or is otherwise no longer valid. Trying to use a dangling pointer leads to unpredictable behavior and often program crashes.



Submit Your Response