If n has a value of 5, then print:
printf("%d %d", n++, ++n); //should be 5 and 7
But I get a weekend of 6 and 7.
Numerous imperceptible modifications lead to this kind of Undefined Behavior. There are tons of results if you are looking for them, for example. this is a question .
Next time compile all included warnings, for example:
Georgioss-MacBook-Pro:~ gsamaras$ gcc -Wall main.c main.c:6:22: warning: multiple unsequenced modifications to 'n' [-Wunsequenced] printf("%d %d", n++, ++n); ^ ~~
printf () calls undefined -behavior. Please see Undefined Behavior and sequence points.
It is not good practice to change the values โโof your variables twice or more in the function argument list