int i = 1;
int j = 1;
printf("%d %d\n", i++ , j+1 );
printf("%d %d\n", ++i , j++ )
وفي 23 سبتمبر 2009 09:48 م، ظهر شبح ابتسامة على وجه مؤيد مارديني وهو يقول:
++i : يعيد قيمة i القديمة ثم يزيد قيمة المتغير بـ1.i = 7 ;
i++
// i = 8
اليس كذلك ؟
It's true that the postincrement and postdecrement operators ++ and --
perform their operations after yielding the former value.
What's often misunderstood are the implications and
precise definition of the word ``after.'' It is not guaranteed that an increment or decrement
is performed immediately after giving up the previous value and before any other part of the
expression is evaluated. It is merely guaranteed that the update will be performed
sometime before the expression is considered ``finished'' (before the next
``sequence point,'' in ANSI C's terminology; see question 3.8).
In the example, the compiler chose to multiply the previous value
by itself and to perform both increments later.
int i = 5;
printf("%d", i++*i++);
// What does this statement print?