Originally posted by: kamper
The stack is function-specific memory. It stores function parameters and return values, stack data and other such things. It grows with every function call and shrinks with every function return. Anything that you declare local to a function gets placed on the stack (and that's why you can't pass pointers to local variables as returns, because once a function returns, it's memory on the stack is invalid).
So that's why my program's pointer was invalid. Thanks for clarifying that. I've actually come across that problem myself and have been totally puzzled. As they say, knowledge is power.