Pointers in c

How Dangling Pointers Works in C?
The dangling pointers are similar pointer just like the normal pointer but it works by taking consideration of a de-allocated object/deleted object. It is nothing but a pointer which actually going to point a specific memory location that is actually deleted and it is called a dangling pointer.

The dangling pointer’s errors can only be avoided just by initializing the pointer to one NULL value. If we try assigning the NULL value to a specific pointer, then that pointer will not at all point to the needed deallocated memory. Assigning the NULL value to the specific pointer helps the pointer not pointing to any specific memory location.

For de-allocating memory of the C dangling pointer concept, free() function is used with a single parameter just to make a pointer into a dangling pointer. This is how the dangling pointer will be created with free() function in the C coding language. There is also another way of creating a dangling pointer. It is variable go out of the scope way of creating a dangling pointer concept.

The Dangling Pointers works just by pointing to the specific memory location which actually contains either some programming code or some code of the operating system. If we accept some value to the specific pointer then it will overwrite the value of the program code.



Posted on by