Here in your example you have a common C language misunderstanding.
You can not return a pointer which points to a local variable!
'poutine' is out of scope when you return from the routine. so 'q' is points an in-valid location.
If you allocate 'poutine' as global variable, it should work.
When it is defined locally, you can treat that the variable is allocated in stack. when returns, the stack is cleard, p is points to invalid location ( that memory or stack reallocated by others.... ).
if you use p= new() or p= alloc() to allocate memory (from the heap ) in the module, unless you use delete() or free() to release the memory, the memory is always valid...
hope this helps.
Message Edited by eGuy on 2009-07-01 02:02 PM