A pointer is a variable that keeps track of other variables’ memory addresses. The addresses of additional memory elements may also be stored in the pointers. When it comes to dynamic memory allocation, they are quite useful. On the other hand, a dangling pointer leads to a memory address or a non-existent variable. The pointer that is hanging around could lead to a variable or memory address that was perhaps freed.