1.

What do you understand by Wild Pointer? How is it different from Dangling Pointer?

Answer»

A pointer is SAID to be a wild pointer if it has not been initialized to NULL or a valid memory address. Consider the following declaration:

int *ptr;*ptr = 20;

Here the pointer ptr is not initialized and in the next STEP, we are trying to ASSIGN a valid value to it. If the ptr has a garbage location address, then that would corrupt the upcoming instructions too.

If we are trying to de-allocate this pointer and FREE it as well using the free function, and again if we are not assigning the pointer as NULL or any valid address, then again chances are that the pointer would still be pointing to the garbage location and accessing from that would lead to errors. These pointers are called dangling pointers.



Discussion

No Comment Found