Path: utzoo!utgpu!watserv1!watmath!att!westmark!mole-end!mat From: mat@mole-end.UUCP (Mark A Terribile) Newsgroups: comp.lang.c Subject: Re: Comparing strings... Summary: Bothering about null statements Message-ID: <444@mole-end.UUCP> Date: 21 Oct 90 01:00:09 GMT References: <1990Oct13.190106.15615@ux1.cso.uiuc.edu> <3330@idunno.Princeton.EDU> <11486@alice.att.com> Organization: mole-end--private system. admin: mole-end!newtnews Lines: 35 > > int strcmp(char *s,char *t) > > { > > for (; *s && *s == *t; s++,t++); > > return *s-*t; > > } > --Andrew Koenig > ark@europa.att.com Note the semicolon on the for(;;) . Note that it's hard to note. Another article on this topic replaced a null statement for a loop body with a continue : while( . . . . . ) continue; IMnsHO, the semicolon null statement is one of the more irritating glitches in C. I prefer for( ; *s && *s == *t; s++, t++ ) {} or while( . . . ) {} It's quite clear that this is an empty, no-effect statement. It's a brace- thing where you expect a brace-thing, and it won't get missed on a faint printout the way a semicolon can be. -- (This man's opinions are his own.) From mole-end Mark Terribile