#include <stdio.h>
void f(int i, int j, int k) {
printf("%d%d%d\n", i, j, k);
}
int main(void) {
int x=1, y = 2, z = 3;
f(x + y, y = x + z, z = x + y);
return = 0;
}
Asked
Active
Viewed 65 times
0

Saucy Goat
- 1,587
- 1
- 11
- 32

vincent
- 101
- 1
- 9
-
4The evaluation order for function arguments is not specified! In your case, it seems to be right to left, which would give the output you report. See here: [Order of evaluation in C++ function parameters](https://stackoverflow.com/questions/2934904/order-of-evaluation-in-c-function-parameters) - although this is for `C++` (but `C` has the same). – Adrian Mole Jan 02 '20 at 00:14
-
2Moral of the story: write your code in such a way that the evaluation order is clearly defined. – Robert Harvey Jan 02 '20 at 00:17