conditional expression evaluation question

adam at prophet.bbn.com adam at prophet.bbn.com
Wed Jan 14 03:34:41 AEST 1987


> For now, I am using the following ugly code:
> 
> 	while (cp < end && triples < MINSKIP) {
>		if ((*cp | *(cp+1) | *(cp+2)) == 0) ++triples;
>		else triples = 0;
>		cp += 3;
>	}

First of all I don't understand what is so ugly about this code.  The
other example with the *cp++'s was subtle and at worst confusing.
This example is not.  The only other objections to this second example
that you might have is that it compiles to significantly more code, or
that you don't like all the parentheses.  The first of these other
objections I cannot answer for you, but the second can be solved by
using array notation as follows:

	while (cp < end && triples < MINSKIP) {
		if ((cp[0] | cp[1] | cp[2]) == 0) ++triples;
		else triples = 0;
		cp = &cp[3];
	}


-- Adam Stock



More information about the Comp.lang.c mailing list