TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: Bob van der Poel 76510,2203 (X)
from: James Jones 76257,562
date: 1991-09-03 01:13:54
subject: #12054-#C fun

#: 12056 S3/Languages
    03-Sep-91  01:13:54
Sb: #12054-#C fun
Fm: James Jones 76257,562
To: Bob van der Poel 76510,2203 (X)

This is one of many places in which C's sloppy type system trips one up.  The
relational operators have a result of type int, and, oddly enough for a
descendant of BCPL, relationals don't elide in the way you were hoping for
(BCPL itself would have done what you wanted, I believe).  So...

if (a == b == 3)

compares a with b, and then compares 1 with 3 if they are equal, 0 with 3 if
they are not.  Since neither 1 nor 0 are equal to 3, the condition will never
be true, and the then clause of the if will never be reached.

There are 2 Replies.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.