Levi Pearson wrote:
On Sep 23, 2006, at 1:49 PM, Dave Smith wrote:
Wrong. In both cases (char* and char[]), the variable itself stores
the address. You do not need the & operator in either case.
In fact, using the & operator is incorrect, because it will give you
the address of the variable that was already holding the address of
the character array, instead of the address of the character array.
No, you are wrong, at least partially. Both a char * and char[]
variable will evaluate to an address, but in the case of char[] that
address is both the address of the first element /and/ the address of
the variable itself. With a char *, the address it is pointing to is
not the same as its own address, so the & operator acts differently on
char * than char[].
At least we agree that the & operator is not needed to print the address
of a character array, which was the original poster's question.
--Dave
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/