What is a dangling pointer?

A dangling pointer is a pointer that points to invalid data or to data which is not valid anymore, for example: This can occur even in stack allocated objects: The pointer returned by c_str may become invalid if the string is modified afterwards or destroyed. In your example you don’t seem to modify it, but since it’s … Read more