From owner-freebsd-hackers Sat Jan 30 23:37:35 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA24168 for freebsd-hackers-outgoing; Sat, 30 Jan 1999 23:37:35 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from gamma.aei.ca (gamma.aei.ca [206.123.6.10]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA24162 for ; Sat, 30 Jan 1999 23:37:33 -0800 (PST) (envelope-from malartre@aei.ca) Received: from aei.ca (ppp-111-17.mtl.aei.ca [207.107.111.17]) by gamma.aei.ca (8.8.5/8.8.5) with ESMTP id CAA27816 for ; Sun, 31 Jan 1999 02:37:29 -0500 (EST) Message-ID: <36B407F7.1617E743@aei.ca> Date: Sun, 31 Jan 1999 02:36:23 -0500 From: Malartre X-Mailer: Mozilla 4.5 [en] (X11; I; FreeBSD 2.2.8-RELEASE i386) X-Accept-Language: fr, en MIME-Version: 1.0 To: hackers@FreeBSD.ORG Subject: some weird C Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This is not really.. for hackers@freebsd.org, but I cannot find the answer anywhere. main() { int x=4; printf("The value of x is %d\n",x); printf("The value of \"x += x++\" is %d\n",x += x++); x=4; printf("The value of x is %d\n",x); printf("The value of \"x += ++x\" is %d\n",x += ++x); } The results are: The value of x is 4 The value of "x += x++" is 8 The value of x is 4 The value of "x += ++x" is 10 I was expecting 9, not 10. since 4+5=9? Why 10? I also noticed that cc is reading from right to left. Cool. Thank You -- [Malartre][malartre@aei.ca][http://www.aei.ca/~malartre/] [French piss me off - Cartman, South Park][http://9.nws.net/] To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message