i=3;
i+=(i++)+(++i);
printf("i+=(i++)+(++i); \ti %d\n", i);
i=3;
i+=(++i)+(i++);
printf("i+=(++i)+(i++); \ti %d\n", i);
i=3;
i+=i++ + ++i;
printf("i+=i++ + ++i; \ti %d\n", i);
i=3;
i=i+ i++ + ++i;
printf("i=i+ i++ + ++i; \ti %d\n", i);
i=3;
i=i++ + ++i +i;
printf("i=i++ + ++i +i; \ti %d\n", i);
return 1;
}
****************************
XP MS QC 19.12.1988 11:59
i+=(i++)+(++i); i 13
i+=(++i)+(i++); i 13
i+=i++ + ++i; i 13
i=i+ i++ + ++i; i 13
i=i++ + ++i +i; i 13
XP gcc 16.12.1996 12:49
i+=(i++)+(++i); i 13
i+=(++i)+(i++); i 13
i+=i++ + ++i; i 13
i=i+ i++ + ++i; i 11
i=i++ + ++i +i; i 13
XP LCC-32 09.08.2004 10:01
i+=(i++)+(++i); i 11
i+=(++i)+(i++); i 11
i+=i++ + ++i; i 11
i=i+ i++ + ++i; i 11
i=i++ + ++i +i; i 13
? :)
A.R.
[...etc...]
>
>XP LCC-32 09.08.2004 10:01
>i+=(i++)+(++i); i 11
>i+=(++i)+(i++); i 11
>i+=i++ + ++i; i 11
>i=i+ i++ + ++i; i 11
>i=i++ + ++i +i; i 13
Google "undefined behavior." You might find your program listed as an
example...
Regards,
-=Dave
--
Change is inevitable, progress is not.
Every statement, apart from i = 3, invokes undefined (or, for the
return, implementation defined) behaviour. If you write
illegitimate code, why do you expect answers?
--
"I'm a war president. I make decisions here in the Oval Office
in foreign policy matters with war on my mind." - GWB 2004-2-8
"If I knew then what I know today, I would still have invaded
Iraq. It was the right decision" - G.W. Bush, 2004-08-02
"This notion that the United States is getting ready to attack
Iran is simply ridiculous. And having said that, all options
are on the table." - George W. Bush, Brussels, 2005-02-22
[snip]
Get a new professor. This one is screwing you.
--
Randy Howard (2reply remove FOOBAR)
"I don't really care about being right you know,
I just care about success." --Steve Jobs
jacob navia wrote:
> You can't use increment or decrement operators more
> than once in an expression.
On the same object, that is.
The OP should also look up "sequence points".
--Toby
And not add a+b+c :)
http://www.lysator.liu.se/c/rat/c3.html#3-3
Ohhh. :(
A.R.