Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ucla-cs!zen!ucbvax!jade!eris!mwm From: mwm@eris.UUCP Newsgroups: comp.lang.c Subject: Re: Possible C Anomaly Message-ID: <5163@jade.BERKELEY.EDU> Date: Sat, 19-Sep-87 20:18:55 EDT Article-I.D.: jade.5163 Posted: Sat Sep 19 20:18:55 1987 Date-Received: Sun, 20-Sep-87 16:44:05 EDT References: <9270@brl-adm.ARPA> <5112@jade.BERKELEY.EDU> <682@hsi.UUCP> Sender: usenet@jade.BERKELEY.EDU Reply-To: mwm@eris.BERKELEY.EDU (Mike (My watch has windows) Meyer) Organization: Missionaria Phonibalonica Lines: 46 In article <682@hsi.UUCP> palmer@hsi.UUCP (Mike Palmer) writes: , mwm@eris.BERKELEY.EDU (Mike (My watch has windows) Meyer) writes: <> < k = (k > 1) ? --k : 1; <> <> No! Consider that you're doing (one way) "k = --k". You still don't know < <... stuff deleted ... < <> < k = (k > 1) ? (k - 1) : 1; <> <> Much better - it's right. < 1) ? k-- : (k = 1); Because the original question was "why doesn't k = ..." work. Also, this displays the bad habit of using something normally used to generate an expression as a statement. 1) ? k-- :; Because it's not legal C. Gotta have an expression between the : and the ;. If you're going to rewrite the original statement "k = (k > 1) ? --k : 1 ;" you'd be better of just to go to if (k > 1) k -= 1 ; if it will work - the semantics aren't quite the same.