Home > Back-end >  About I into the stack
About I into the stack

Time:09-17

As is known to all the C language function and participate in turn into the stack from right to left, calling print () function, and then introduced to different parameters, after the function call, will follow after the "advanced" so f () function to print the result is below 4321
 # include & lt; Stdio. H> 
Void f (int I) {
Printf (" % d, % d, % d, % d \ n ", I, i++, i++, i++);
}
Void f2 (int I) {
Printf (" % d, % d, % d, % d \ n ", I, i++, + + I + + I);
}
Int main (void)
{
int i=1;
Int a=1;
F (I);
F2 (I);
return 0;
}

But f2 () function to print the result is 4344, according to the "advanced" principle of stack should be 4332, but is wrong), anyone know the reason?

CodePudding user response:

+ + I, I, after the return value is increasing i++ the return value is temporary variables (incrementing before I value)
So the f2 is equivalent to
Printf (I, increasing for the last time before I, I, I)

CodePudding user response:

It is well known that the wrong don't have to see the content behind the
As is known to all that is wrong without this
Here the deciding factor is evaluated order
Has nothing to do and stack order
The output meaningless compiler has a variety of different understanding
  • Related