When you do anything with a pointer that is returned by a function, like dereference it, which is a typical thing to do with a pointer, you need to know that the object that your pointer points to exists. However, the pointer you return points to an object that exists in scope of the returning function; after the function has returned, the function scope no longer exists and the object goes down with it. It is like holding an address of a house that has been demolished and hoping you can spend the night there.