C bites / programming style

Mike Shannon mikes at 3comvax.UUCP
Sat Aug 24 03:37:13 AEST 1985


With regard to:
	if(condition);		/* the bug is the seimcolon on this line */
		statement;	/* this statement was intended to be
				 * executed iff the condition was true
				 */
--------------------
	I avoid getting bitten in this way by ALWAYS using {}'s after
if, while, etc.  Even when I have a null statement as the body of an
while or for, I do it this way:
	for(i = 0; i < MAX; i++) {
	}
Always using braces with if/else also removes ambiguity concerning
"which if an else belongs to."
				-Michael Shannon (hplabs!oliveb!3comvax!mikes)



More information about the Comp.lang.c mailing list