Quote:
Originally Posted by
aaronwong
Thanks to you all for your comments!
So it is believed that:
(1) there is no actual functional difference between the two methods;
Not as you've written them, no.
Quote:
(2) it is needed to pass a pointer-to-pointer to a function only if the original value of the "pointer-to-pointer" parameter is used in the function, or we want to change its value in this function. Otherwise, it only increases the function invoking overhead.
I think that's correct, though pointers always make for awkward language.
Quote:
(3) it should be careful when return a local pointer value in a function, because a pointer pointing to stack space(local variables) returned to the invoker points to an invalid space. The pointer returned from a subroutine should point to heap space(like malloc()) or global&static variables.
Quite right, stack variables are only valid until the function returns. You
can give stack pointers to functions you're calling however, just like you did inside the main() of your first example, since that function is guaranteed to return before main() does.