On 9/17/07, Von Fugal <[EMAIL PROTECTED]> wrote: > Correct me if I'm wrong, but char ** temp still lives on the stack, even > if you assign it to array once changing array to be passed by reference, > it's still going to point to an obsolete stack space, from which Bad > Things TM will happen. It just so happens in this case that obsolete > stack space is never reused because that was the last function call, so > it works... but it's still not right.
My understanding is that since temp is allocated with new[], the memory that temp points to is on the heap. Because of this, when you modify array to point at that heap location, even though the function returned and the stack invalidated, the temp pointer along with is, array still points to the heap and that memory is still valid. Of course it now becomes your responsibility to delete[] the array when finished since it's not freed when the function returns. At least that's how I hope it works since I don't want to rewrite this program :) -------------------- BYU Unix Users Group http://uug.byu.edu/ The opinions expressed in this message are the responsibility of their author. They are not endorsed by BYU, the BYU CS Department or BYU-UUG. ___________________________________________________________________ List Info: http://uug.byu.edu/mailman/listinfo/uug-list
