A dangling pointer is a pointer that points to a memory location that is no longer valid. This can occur when a memory block is dynamically allocated and then subsequently freed, but the pointer to that memory block is not set to NULL or is not properly updated to point to a different valid memory location. Attempting to access the memory through the dangling pointer can lead to undefined behavior, such as a program crash or unexpected results.
//Dangling Pointer #include<stdio.h> #include<stdlib.h> int * value() { int a=10; return &a; } int main() { int *ptr=NULL; ptr=value(); //&a printf("%d",*ptr); return 0; }To download raw file Click Here
returned -1073741819
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions