On 9/15/07, Nathaniel Price <[EMAIL PROTECTED]> wrote:
> The problem is that the char ** pointer that points to the words array
> is being passed to GrowArray() by value and not by reference. Thus the
> pointer to the new array you create inside the function is lost as
> soon as you return out of it, since the variable array is only a copy
> of the pointer to words and not the original pointer itself. Change
> the function declaration to this (if I recall the syntax for passing a
> pointer by reference) and that should fix it:
>
> void GrowArray(char ** & array, int oldSize, int newSize)

GAH!  I swear I knew that!  Really!

Thanks a ton for the quick reply, it was exactly what I needed.  On a
related note, is there any benefit of using a char ** & instead of a
char *** ?  I seem to remember a discussion someplace (maybe /.) where
people seemed to favor the triple pointer because it was more obvious
what was going on (or at least, it was harder to overlook than the
pointer-by-reference).

Functionally they are the same I guess, but I just wondered what you
and others might think.

Thanks again.

Nick
--------------------
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

Reply via email to