There are two problems. First is that the order in which the expressions k++
, k
, and ++k
in the printf
call are evaluated is not specified; the compiler is free to evaluate them in any order it sees fit. Second is that an object may not have its stored value updated more than once between sequence points by the evaluation of an expression. Both k++
and ++k
attempt to update the value stored at k
, and there is no sequence point between those expressions, so the behavior is undefined; any result is permitted.