Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!yale!think!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Pointer question Message-ID: <16597@haddock.ima.isc.com> Date: 3 May 90 17:06:08 GMT References: <19515.263eadf8@oregon.uoregon.edu> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Distribution: usa Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 19 In article <19515.263eadf8@oregon.uoregon.edu> slewis@oregon.uoregon.edu writes: >[Assuming declarations int i,j; int **p, *a, *b;] My understanding is that >a[i] is equiv to *(a+i). Now, this implies some strange things, right? >First, since (pointer) addition is commutative, a[i] == *(a+i) == i[a]. I've >seen this stated before in this newsgroup. Right. >But are the following assertions true: >1. p[i][j] == *( *(p+i) + j) == j[p[i]] == j[i[p]] >2. a[b[i]] == *( a + *(b+i)) == b[i][a] == i[b][a] Looks right to me. However, I maintain that, outside of the Obfuscated C Contest, the identity a[i]==i[a] is worse than useless. Never *ever* use it! (I argued that X3J11 should have eliminated this misfeature, just as they did with "a + = 1", but I wasn't convincing enough.) Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint