Answers for "example of dangling pointer"

C++
1

Explain the concept of Dangling Pointer and Null Pointer with Examples? Provide brief details of the scenarios in which pointer acts as dangling pointer.

Explain the concept of Dangling Pointer and Null Pointer with Examples? Provide brief details of
the scenarios in which pointer acts as dangling pointer.
Posted by: Guest on December-24-2021
3

Dangling Pointer

int *p = new int; // request memory
*p = 5; // store value

delete p; // free up the memory
// now p is a dangling pointer

p = new int; // reuse for a new address
Posted by: Guest on May-27-2021

Browse Popular Code Answers by Language