答案是 45。我不明白这东西是如何工作的。
main()
{
int a =10;
int i = a++ + ++a + a++ + ++a;
printf("%d , %d ", i,a);
}
最佳答案
实际上输出是一个未定义的行为
,这很好。
来自 C99 标准的是 6.5 表达式,§2
Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be read only to determine the value to be stored.
The order of evaluation of the operands is unspecified. If an attempt is made to modify the result of an assignment operator or to access it after the next sequence point, the behavior is undefined.
关于c - 后增量、前增量和运算符优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18515351/