argc[argv]
Alan S. Driscoll
alan at allegra.UUCP
Sat Dec 24 08:30:18 AEST 1983
From: Laws at SRI-AI.ARPA
Newsgroups: net.unix
Subject: argc[argv]
From: Ken Laws <Laws at SRI-AI.ARPA>
Beginners may have trouble with the statement that a[b] is entirely
equivalent to *(a+b). This is only true for character arrays. For
other types of arrays the translation is *(a+b*sizeof(*a)).
-- Ken Laws
No, that's incorrect -- "a[b]" is equivalent to "*(a+b)". If "a" is a
pointer, and "b" an integer, then the multiplication you described will
take place, but not for the reason you gave. The multiplication is a
result of the way the "+" operator is defined in C. In "*(a+b)", the
very same multiplication will take place.
Alan S. Driscoll
AT&T Bell Laboratories
More information about the Comp.unix
mailing list