On 9/17/07, Derek Davis <[EMAIL PROTECTED]> wrote:
> The memory that temp points to is indeed on the heap.  However, the
> value of array is passed by value, so it will be the same value when
> it returns.  If it were passed by reference, as preceding the
> parameter with an & would do, the new value would be returned.  What
> this means is that within the function, you delete what array points
> to, then tell array to point to temp.  When the function returns,
> array is not changed due to pass-by-value, so it points back to where
> it did before the function, which is memory that you have now deleted.
>  The memory you allocated in the function is still there, but noone is
> pointing to it.

Arrays (or char**) are pointers and not passed by value.  When you
pass an array as an argument to a function, you are passing the
pointer to the 0th (first) location in that array.

-- 
Alex Esplin
--------------------
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