关于c语言的printf所出现的问题

他们两怎么会输出不同捏,就很奇怪啊,怎么正文还得三十字啊啊。

img

img

你的代码是Undefined behavior
因为C/C++语言标准里没有规定函数参数的计算顺序,编译器可以按任意顺序来计算函数参数值。
因此你代码中a=3和a=10的计算顺序是不确定的,得到的结果也就不一样。

https://en.cppreference.com/w/c/language/eval_order

Order of evaluation of the operands of any C operator, including the order of evaluation of function arguments in a function-call expression, and the order of evaluation of the subexpressions within any expression is unspecified (except where noted below). The compiler will evaluate them in any order, and may choose another order when the same expression is evaluated again.
(1) If a side effect on a scalar object is unsequenced relative to another side effect on the same scalar object, the behavior is undefined.

i = ++i + i++; // undefined behavior
i = i++ + 1; // undefined behavior
f(++i, ++i); // undefined behavior
f(i = -1, i = -1); // undefined behavior

(2) If a side effect on a scalar object is unsequenced relative to a value computation using the value of the same scalar object, the behavior is undefined.

f(i, i++); // undefined behavior
a[i] = i++; // undefined bevahior

相同编译器吗?

补充问题

img