一个关于C语言 printf里输出顺序的问题

#include <stdio.h>
int main()
{
int i = 0;
printf("%d %d %d\n", i+1, ++i, i++);
return 0;
}

输出为3 2 0
运算的顺序是怎么样的?

从右至左

先输出最右边的i++,此时i为0,输出0,i变成1
之后输出中间的++i,此时i为2,输出2
最后输出最左边的i+1,为3
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-04-22
C99 6.5.2.2 Function calls 10.The order of evaluation of the function designator, the actual arguments, and subexpressions within the actual arguments is unspecified, but there is a sequence point before the actual call.
第2个回答  2015-04-22
i++,++i, i+1
相似回答