the "broken" statement - (nf)

Spencer W. Thomas thomas at utah-gr.UUCP
Mon Oct 17 12:40:41 AEST 1983


Ok, here is a solution (admittedly gross, but works) using only
"standard" C.  Of course, the terminal action must be an expression (no
for or if statements allowed).  An example follows.

/* Construct to perform a terminal action at the end of a loop. */
/* Note - should really cast (term_act) to (int), else lint complains */
#define AT_END(log_exp,term_act)   ( (log_exp) ? TRUE : ( (term_act),FALSE ) )

	for ( i = 0; AT_END( i < n, not_found() ); i++ )
		if ( some_condition )
		{
			found();
			break;
		}

=Spencer



More information about the Comp.lang.c mailing list