Originally Posted by
laserlight
The name dropping makes no difference: defective learning material is defective. Of course, it could be that the undefined behaviour is explained, but you failed to read it properly, or that the material is sufficiently old such that what it states no longer applies, in which case it is defective other than as a historical artifact.
there is no undefined behavior, so let me prove my point.
Thus c arguments have right from left convention following programm
Code:
main()
{
int i = 5;
printf ("%d %d %d %d %d", i, i++, i++, i++, i++);
}
will give output as 9 8 7 6 5 so here my points prove that the arguments convention is from right to left
now the pre increment behaviour
if we add a pre-increment operator to variable it first increments the variable value whether the variable is used or not so like as following programm
Code:
main()
{
int i = 5;
printf ("%d %d %d %d %d", i, ++i, ++i, ++i, ++i);
}
will give output as 9 9 9 9 9
so as in the thebenman's programm the first the variable value is passed to the printf function which is 6, but pre-increment operator increment variable value and by doing that the value is get incremented to 9 because there is two more post operators are in the processing so pre-increment operator changes the value of variable i to its final increment. Thus i become 9 in first, now post increments prints their values which is get incremented after the value is been used the first post increment operator increments the value of i is to 7, while second will increment to 8, and the last is the preincrement it self has value which is needed to be print so last the value is passed is 9 thus we got results
9 7 8 9 and thus c arguments passing convention is from right to left the output is get printed 9 8 7 9.
Try above programm's and i bet they will give same output in any compiler.