I wrote a simple code for printf in C with unary prefix operator as the following:
#include <stdio.h>
int main() {
int i=5;
printf("%d %d %d",++i,i,i+1);
return 0;
}
And this is the output:
6 6 6
Now, what I have understood is that C compilers usually execute printf() arguments from right to left and so in that case i+1 should be 6 (since i is 5), i should be 5 and ++i would first become 6 and then print. Hence expected output in my opinion should be:
6 5 6
If it executes from left to right, we should get 6 6 7
.