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

Dave Harris Dave.Harris at f14.n15.z1.fidonet.org
Mon Jun 17 00:18:45 AEST 1991


 >From: dm at phsbbs.princeton.nj.us (Doron Meyer)
 >Date: 11 Jun 91 12:09:44 GMT
 >Organization: Princeton High School, Princeton, New Jersey
 >Message-ID: <XamD43w164w at phsbbs.princeton.nj.us>
 >Newsgroups: comp.lang.c

 >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++);

you could go:

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

I have seen both done but actually tend to use it the way you do.

Dave Harris.
 


 

--  
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!15!14!Dave.Harris
Internet: Dave.Harris at f14.n15.z1.fidonet.org



More information about the Comp.lang.c mailing list