Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!uccba!mead!dem From: dem@mead.UUCP (Dave Myers) Newsgroups: comp.lang.c Subject: Re: What's a C expert? Message-ID: <338@mead.UUCP> Date: 24 Aug 89 14:06:49 GMT References: <12214@well.UUCP> <6057@microsoft.UUCP> <1336@atanasoff.cs.iastate.edu> Reply-To: dem@mead.UUCP (Dave Myers) Distribution: all Organization: Mead Data Central, Dayton OH. Lines: 47 In article <1336@atanasoff.cs.iastate.edu> hascall@atanasoff.cs.iastate.edu.UUCP (John Hascall) writes: >In article <6057> paulc@microsoft.UUCP (Paul Canniff 2/1011) writes: >}In article <12214@well.UUCP> tmh@well.UUCP (Todd M. Hoff) writes: > >}> What do you need to know to be an expert C programmer? > >}How about ... understands why a[i] equals i[a] and CAN EXPLAIN IT, > > a[i] = *(a+i), i[a] = *(i+a), a+i = i+a > Hmmm.... I don't claim to be a C expert, but let's take a trivial case. An array of anything with a size different from that of int will do. int i; struct element { int x[BIGNUMBER]; } a[WHATEVER]; a[i] == *(a + (i * sizeof(element))) i[a] == *(i + (a * sizeof(int))) or a[i] == *(a + (i * sizeof(int) * BIGNUMBER)) i[a] == *(i + (a * sizeof(int))) Clearly, these are not equal. By the same (or at least a similar) token, if you do, struct element *b; i = b; i++; b++; printf("%d", i == b); you will get a 0, meaning that i and b were not incremented by the same amount. -- David Myers (513) 865-1343 Mead Data Central This Data Fabrication Technology P.O. Box 933 space mead!dem@uccba.uc.edu Dayton, Ohio 45401 available. ...!uccba!mead!dem