Increment Counters in declaration or in loop? (style question)

Doron Meyer dm at phsbbs.princeton.nj.us
Tue Jun 11 22:09:44 AEST 1991


Hello net land.  What is the 'preferred' stylistic method of incrementing
counters?  For example, this simple for loop.

for (count=0; count<4; count++)
{
  printf("name[%d]: %c\n", count, ptr++);

In this instance, the loop counter is incremented in the declaration of the 
for loop, and the ptr variable, which still gets incremented each time the 
loop cycles, is incremented within the body of the loop.

Is this more of a matter of personal opinion than anything else?  If so, 
what are your opinions?

-----
Doron Meyer, System Administrator Emeritus, Princeton High School
DNS: dm at phsbbs.princeton.nj.us        UUCP: ...!princeton!phsbbs!dm
PSTN: 609-921-2978 USnail: 64 Farrand Road / Princeton, NJ 08540



More information about the Comp.lang.c mailing list