rosalia@tekig4.UUCP (Mark Galassi) (06/18/85)
In article <459@rtech.UUCP> jas@rtech.UUCP (Jim Shankland) writes: >> array==pointer ... is only true when "array" is being passed >> or received as a parameter. >... "a[b]" is completely, syntactically, semantically, >and rigorously IDENTICAL to "*(a+b)" (except, again, in an actual declaration). >Of course, for the above to make sense, one of the operands must be a >pointer to something, and the other an integral type; but it doesn't matter >which is which. It follows that "a[b]" is equivalent to "b[a]" -- a >notion that most people will not accept without a little head-scratching. >Jim Shankland I don't agree with you: *(a+b) is incorrect, and will not pass lint's checking. Whay you want is *a + b, and the compiler will scale b so that if a points to a 16-bit quantity, you will get *(a + 2b) and so on. I also would like to see an example of your a[b] and b[a]: indexing an array by pointers is strange, because the pointer b in a[b] would have a value like 10 or 54 or something that makes sense in your array. But then taking b[], you might access very weird machine locations. Mark Galassi ...!tektronix!reed!rosalia