Is there a meaningful difference between a null pointer and a dangling pointer? It seems like these are both terms used for pointers that don’t point to anything. Is the idea that a dangling pointer used to refer to something and now doesn’t — where a null pointer is just a pointer that does not refer to anything (regardless of what it pointed to in the past)?
Is there a meaningful difference between a null pointer and a dangling pointer? It
Share
A null pointer just means the pointer isn’t pointing to anything, or in some languages means it is unknown what it is pointing at. But because it is a null pointer, you know this, the code knows this, so no problem. A dangling pointer is one that you think is pointing at something but in reality is no longer there, hence the pointer is actually inaccurate but doesn’t know it.