Re: printf output



On Mon, 16 Feb 2009 19:32:37 -0800 (PST), Keep Asking
<ask8y@xxxxxxxxx> wrote in comp.lang.c:

What is output of following printf should be?

There is nothing that it "should be".

i=0;
printf("i=%d i++=%d i++=%d", i, i++, i++)?

I was surprised when I was the print out.

You have no business being surprised, because you had no right to
expect anything. You have broken the rules and generated undefined
behavior.

Once you do that, the C language does not specify or care what
happens. Anything is as right or wrong as anything else.

You have modified the (type unknown, but assume int) object 'i' more
than once, and also modified it and read its value separately, both
without a sequence point in between.

Search this group on Google groups for the phrase "sequence point" to
see many, many discussions.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
.



Relevant Pages

  • Re: Why En101?
    ... this breaches the 'terms of service' on google groups. ... unless they are a marketplace group with specific interests. ... En101 has positioned itself in the marketplace with a proven business ... New enrollees appear in REAL TIME ...
    (rec.crafts.textiles.quilting)
  • Re: Im Back!
    ... And I am back in business. ... No effort whatsoever to help transition their newsgroup customers. ... Am I doomed by selecting Giganews? ... You could have used Google Groups for free you daft old trout. ...
    (soc.culture.scottish)
  • Re: Furnace hot surface ignitor pricing question
    ... Anyone who knows the basic sequence of operations could ... I don't wanna be in that business. ... I had to place service call for furnace after waking in on recent chilly ...
    (alt.home.repair)
  • Re: Big front wheel skates rule for rough street skating
    ... other 1% cyber stalk me. ... most USENET users don't accept advertising. ... So whether your business is a good one or not makes no difference. ... Google Groups is destroying the USENET archive. ...
    (rec.sport.skating.inline)
  • Re: Fuck off Ian F, Fuck off Plowman, Fuck off Lawrence, et al [Re: Fuck off Barker Re: Proposal: ne
    ... is so terrible that everyone is attacking him like this? ... don't you ask Sofa Spud to prove he runs the business he lies about? ... Google Groups is just one of many ways to access UMTM. ...
    (uk.media.tv.misc)

Loading