quote: Original post by doctorsixstring
Although it should compile fine, it will not perform correctly. Local variables are created at the start of a function, and destroyed when the function is done. If you assign a pointer to a local variable (which will soon be destroyed) you are left with a dangling pointer (memory leak).
Incorrect. He is using static local vaiables. Static local variables lives on when your function is inactive.