I'm trying to do a simple pointer return but the program keeps crashing.
There are a number of things that could cause that crash. The first one is always, is the pointer null or uninitialised?
If you want to track the actual crash, it's normal to run the program in a debugger and let it crash. The debugger will show the function it crashed in, and the call stack. If the program was built for debug, you'll also be able to see local variables for each function in your program that's in the call stack.
Once you can see where it's crashing, you can work backwards to work out why.