"for" loops in C ...

William E. Davidsen Jr davidsen at steinmetz.ge.com
Fri Oct 21 01:07:01 AEST 1988


In article <23299 at amdcad.AMD.COM> tim at crackle.amd.com (Tim Olson) writes:

| Didn't anyone else see what Dr. Andrews was pointing out?  Saying that
| you should avoid the construct 1["string"] is *like* saying you should
| avoid a for loop, because both are fundamental constructs that a broken
| C compiler may not implement correctly.  Avoiding something fundamental
| just because some compiler somewhere gets it wrong is no excuse -- FIX
| THE COMPILER.

  I would suggest that there is a very good reason to avoid int[ptr],
being that it's hard to read. Obviously it's part of the language, but
is there any reason to use it other than to prove how well you
understand C? That's real question, I would be pleased to learn that
there really is some benefit, but I don't see much between int[prt],
ptr[int] and *(ptr+int) other than readability.

  Obviously "string"[int] is legal, too, but somewhat less than readable
to the casual programmer.
-- 
	bill davidsen		(wedu at ge-crd.arpa)
  {uunet | philabs}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me



More information about the Comp.lang.c mailing list