[Solved] Increment and decrement operators in one statement in C [duplicate]


The order in which the arguments passed to a function are evaluated is not specified, and the order of evaluating the operants of + is unspecified, too.

So in printf("%d %d", i+1, i-1), for example, you cannot rely on the order of evaluation of the arguments; i+1 might be evaluated after i-1, actually; You will not recognise, since the evaluation of the one does not effect the result of the other.

In conjunction with “side effects” like the post-increment i++, however, the effect of incrementing i at a specific point in time might influence the result of other evaluations based on i. Therefore, it is “undefined behaviour” in C, if a variable is used more than once in an expression and a side effect changes its value (formally, to be precise, if there is no sequence point in between).

0

solved Increment and decrement operators in one statement in C [duplicate]