问题
#include<stdio.h>
int main()
{
void add();
int i=2;
add(i++,--i);
print("%d",i)
}
void add(int a,int b)
{
print("%d %d",a,b);
}
/*what are a and b's value i am actually not getting the answer why b is 2 */
回答1:
in line 6 where add() is called
first args is i++ so it will send value 2 ie value of i to the function and then add 1 now i=3.
second args is --i now it will subtract 1 and iwill now be 2 again and then send value 2 to function
So I think your answer will print 2 2 (that is value of a and b) 2 (that is value of i)
来源:https://stackoverflow.com/questions/23926779/pre-increment-and-post-increment-function-call