Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Todd Carnes Newsgroups: comp.lang.c Subject: Re: confusion about behavior Date: Mon, 15 Aug 2011 01:57:25 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 30 Message-ID: References: NNTP-Posting-Host: uqlV+6kNo2Z0TnMsKGN6tA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Pan/0.133 (House of Butterflies) X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:9411 On Sun, 14 Aug 2011 12:06:19 -0700, Keith Thompson wrote: > LJ writes: >> int a = 2; >> int b = 3; >> c = a+++b; >> What will be the value of c?? >> Shouldn't it be undefined depending upon the interpretation?? > > In a professional environment, the result will be "go back and fix the > code, then we'll look at it". > > The assignment is equivalent to > > c = a++ + b; > > due to the "maximal munch" rule (the same rule that makes "a+++++b" a > syntax error rather than "a++ + ++b"). The code is badly formatted and > difficult to read, but there is no ambiguity. > > I'll assume that's enough to tell you what the code does. If not, feel > free to ask. So, you're saying that it will first increment a by 1, then add the result to b? What prevents it from being interpreted as a + ++b? Nevermind, I just realized that you get the same result either way. Todd