&& operator (was: Re: comma operator)

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Aug 19 15:17:51 AEST 1989


In article <20348 at sequent.UUCP> paulr at crg3.UUCP (Paul Reger) writes:
-while ((ch = getchar()) != EOF && ch != '\n')
-Is there any assurance in any C standard that the left expression will
-always be evaluated first, with the right following it ??  I mean for
-purposes of optimization, the right should be evaluated first, unless
-there is something in some standard somewhere limiting such
-optimizations...

Any introductory C textbook will tell you how the && operator works.
Certainly the standard reflects the way the operator has always been
defined.  (I'm refraining from simply answering the question, because
I think you should find such a textbook and study it.)

-I'm from Ada-land where such problems are handled by the 'and then'
-clause.

Whoopee do.

It's not a problem.



More information about the Comp.lang.c mailing list