LinuxSA Mailing list archives
Index:
[thread]
[date]
[subject]
[author]
[stats]
From: Stephen White <spwhite@chariot.net.au>
To : <linuxsa@linuxsa.org.au>
Date: Sat, 2 Jun 2001 21:23:57 +0930 (CST)
Re: A view on MS and licencing ...
On Sat, 2 Jun 2001, Daryl Tester wrote:
> > Can you still explain why it's **argv, not *argv[]? :)
>
> And I prefer *argv[] to **argv; although there isn't much difference,
> *argv[]'s intent is clearer (pointer to array of char pointers0.
I was being a bit of a bastard there. It's an old argument from the
C echo on FidoNet that was never resolved. Here's the FAQ answer.
# Since arrays decay immediately into pointers, an array is never actually
# passed to a function. Allowing pointer parameters to be declared as arrays
# is a simply a way of making it look as though the array was being
# passed--a programmer may wish to emphasize that a parameter is
# traditionally treated as if it were an array, or that an array (strictly
# speaking, the address) is traditionally passed. As a convenience,
# therefore, any parameter declarations which ``look like'' arrays, e.g.
#
# f(a)
# char a[];
# { ... }
#
# are treated by the compiler as if they were pointers, since that is what
# the function will receive if an array is passed:
#
# f(a)
# char *a;
# { ... }
#
# This conversion holds only within function formal parameter declarations,
# nowhere else.
So *a and a[] are identical only within parameters, which means that
int main(int argc, char **argv)
int main(int argc, char *argv[])
are identical.
--
spwhite@chariot.net.au
--
LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject
Index:
[thread]
[date]
[subject]
[author]
[stats]
Return to the LinuxSA Mailing List Information Page