5[array] (was Re: "for" loops in C ...)

Scott Bigham sbigham at dukeac.UUCP
Thu Nov 3 10:50:15 AEST 1988


In article <10742 at cup.portal.com> ts at cup.portal.com (Tim W Smith) writes:
>I don't know about i[ptr] being less readable than ptr[i].  Most people I
>have heard would say when describing an algorithm in English, "Then you take
>the ith element of the array and multiply by foo".  i[array]*foo has the
>words in C in the same order they would be spoken.

a[b] looks like an array reference, so, naive programmer that I am, I assume
that it _is_ an array reference.  In particular, I assume that a is an array
and b is an index into that array.  Something that does otherwise is less
readable to me, and I suspect I'm not alone.

The point is, is there ever any practical reason to use this construct?  Do
you ever use it?  Does anyone?

						sbigham

-- 
Scott Bigham                         "The opinions expressed above represent
Internet sbigham at dukeac.ac.duke.edu   me and everyone that agrees with me.
USENET   sbigham at dukeac.UUCP          If that includes Duke University,
...!mcnc!ecsgate!dukeac!sbigham       I'll be amazed."



More information about the Comp.lang.c mailing list