argc[argv]
edhall%rand-unix at sri-unix.UUCP
edhall%rand-unix at sri-unix.UUCP
Mon Dec 19 11:54:00 AEST 1983
In C the addition of an integer to a pointer implicitly does the
multiplication you attempt to do explicitly (i.e., your example ends
up doing the multiplication twice). This follows from the rules for
C pointer arithmetic, in which adding to a pointer works in units of
N bytes, where N is the size of the object pointed to. (Look it up
in K & R...) The equivalence of a[i] and *(a+i) works for all
pointers `a' and integer types `i'.
Perhaps you were confused by the need for the multiplication in
assembler-language programming.
-Ed Hall
edhall at rand-unix (ARPA)
decvax!randvax!edhall (UUCP)
More information about the Comp.unix
mailing list