From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2001-01-02 20:51:40
On Tue, Jan 02, 2001 at 07:15:32PM +0100, Spiro Trikaliotis wrote:
> Forgive me, but if my memory serves me right, C (at least pre-ANSI) does NOT
> define the order in which this will be evaluated, so the second part (c!=62)
> might be evaluated BEFORE the first part with the assignment, in that case,
> this will NOT evaluate to the expected condition.
That is incorrect. C evaluates boolean expressions as shortcuts with each
boolean operator being a sequence point. If the left operand is enough to
determine the value of the expression result, all others will not get
evaluated. Because of this, one can write things like
char* P;
...
if (P && *P != '\0')
Code like
int C;
while ((C = getchar()) != '\0' && C != EOF) {
...
}
is absolutely correct C code.
Regards
Uz
--
Ullrich von Bassewitz uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:37 CET