Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!chad
From: chad@csd4.csd.uwm.edu (D. Chadwick Gibbons)
Newsgroups: comp.lang.c
Subject: Re: comma operator
Message-ID: <3905@csd4.csd.uwm.edu>
Date: 19 Aug 89 06:34:39 GMT
References: <63244@linus.UUCP> <2300@oakhill.UUCP> <2650@aplcen.apl.jhu.edu> <20348@sequent.UUCP>
Sender: news@csd4.csd.uwm.edu
Reply-To: chad@csd4.csd.uwm.edu (D. Chadwick Gibbons)
Organization: University of Wisconsin-Milwaukee
Lines: 15

In article <20348@sequent.UUCP> paulr@crg3.UUCP (Paul Reger) writes:
|Considering the construction:
|
|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 ??

	It's mentioned in K&R, and most likely the standard; many C programs
rely on the property of boolean evaluation: left to right.  If the first
expression ((ch = getchar()) != EOF is false, there is no need to complete the
second comparison, so the compare falls through.  This is a reliable C
operation.
--
D. Chadwick Gibbons - chad@csd4.csd.uwm.edu