a style question
Steve Emmerson
steve at groucho.ucar.edu
Mon Oct 1 05:49:08 AEST 1990
In comp.lang.c you write:
>Since I going to be doing my first team effort I want to know if this is bad
>style:
> for(x=0;x!=100;x++) ...
It's OK, though some improvements could be made. Old-timers would
ususally write "x < 100" rather than "x != 100" as it expresses the
sense of direction (incrementation) slightly better, and they're more
used to seeing it that way.
A slightly more important improvement would be to use a symbolic
variable or constant for the, otherwise, non-obvious "100" value.
Something like
# define NUM_ELEMENTS 100
for (x = 0; x < NUM_ELEMENTS; x++) ...
Note also the use of additional whitespace.
Steve Emmerson steve at unidata.ucar.edu ...!ncar!unidata!steve
More information about the Comp.lang.c
mailing list