- If a pointer is pointing any memory location, but meanwhile another pointer deletes the memory occupied by the first pointer while the first pointer still points to that memory location, the first pointer will be known as a dangling pointer. This problem is known as a dangling pointer problem.
- Dangling pointer arises when an object is deleted without modifying the value of the pointer. The pointer points to the deallocated memory
Sandhya Answered question June 28, 2023
Dangling Pointer occurs when a pointer pointing to a variable goes out of scope or when an object/variable’s memory gets deallocated. Also, the occurrence of Dangling Pointers can result in some unexpected errors during the execution of a program, so we have to make sure to avoid them while writing a program.
Sandhya Answered question June 28, 2023
