printf - Printing order in C -
this question has answer here:
- why these constructs (using ++) undefined behavior? 12 answers
- undefined behavior , sequence points 4 answers
int x=10; printf("%d %d %d\n",x,++x,x++); printf("%d %d %d",x,x+20,x+30); it printing output as
12 12 10 12 32 42 why order in first printf in reverse order , why not in second printf statement? found in book c uses reverse printing order.
your code has undefined behavior ("ub"). thus, can happen.
specifically, rule violated 1 must not read , write same variable without sequence-point except determine value write.
Comments
Post a Comment