e1?(void_e2):(void_e3) so, is it legal or what?

Cary Timar cary at methods.UUCP
Tue Aug 26 10:26:05 AEST 1986


In article <248 at desint.UUCP> geoff at desint.UUCP (Geoff Kuenning) writes:
>
>Unfortunately, Brett is incorrect here.  You can't use if/then/else to write:
>
>	for (i = up ? 0 : 99;  up ? (i < 100) : (i >= 0);  up ? i++ : i--)
>	    {
>	    /* complex loop body */
>	    }
>
>without duplicating code.  On the other hand, anywhere you want do

What about:

	if (up)
		{
		i = 0;
		step = 1;
		}
	else
		{
		i = 99;
		step = -1;
		}
	for (; i < 100 && i >= 0; i += step)
		{
		/* complex loop body */
		}
	
????

			-- Cary Timar /* NOT REACHABLE */
			< Generic Disclaimer >



More information about the Comp.lang.c mailing list