C bites (Null loop-bodies)

Richard Welty weltyrp at rpics.UUCP
Sat Aug 31 10:18:52 AEST 1985


> > 	I put null loop-bodies on a separate line like in the following
> > example.
> > 
> > 		while (eatup() != '\n')
> > 			;
> 
> Putting the semi-colon on a separate line does help make it clear
> that the body of the loop is intentionally null, but what I like
> even better is:
> 
> 		while( eatup() != '\n' )
> 			continue;
> 
I personally like to use {} in all cases ... thus:

	while( eatup() != '\n'){}
or
	while( eatup() != '\n')
	    {}
or even
	while( eatup() != '\n')
	{
	}
By using the {} all the time, even for null cases, I insure
that things like
	if( cond);
don't happen ...
-- 
				Rich Welty

	(I am both a part-time grad student at RPI and a full-time
	 employee of a local CAE firm, and opinions expressed herein
	 have nothing to do with anything at all)

	CSNet:   weltyrp at rpi
	ArpaNet: weltyrp.rpi at csnet-relay
	UUCP:  seismo!rpics!weltyrp



More information about the Comp.lang.c mailing list