> (E-Mail Removed) (prashna) wrote:
> > I am new to C and I am in a code review project( the review has to
> > be done with respect to some predefined rules)and I came across rule
> > which states "The right hand operand of a && or || operator shall not
> > contain side effects.".Please let me know what are these side effects?
> Joona has already explained what a side effect is; let me add a remark
> about this rule.
> It stinks.
> It stinks to high heaven, because it makes some useful constructs
> impossible for, AFAICT, no good reason at all. For example, it would
> disallow this line:
> while (--lim>0 && (c=getchar())!=EOF && c!='\n')
Interestingly, it would also disallow
while (x-- > 0 && getchar() != EOF)
because getchar() has side effects of its own regardless of what
is done with the return value.
"I am worth much more brick-bat!!"