Sometimes its very hard to tell that in what order the expression will be evalauted. Is their any set of rules to know that the expression i have written will show undefined behaviour?
The expression : printf("%d %d\n", ++n, power(2,n)); its very hard to say wheather the ++n is evaluated first or the power(2,n). This line is written in K&R. However, I see this expression absoultely fine. I'll assume that n will be incremented and used by the function call power(2,n).
Also, an expression like A[i++] = A[j++]. Right side of the assignment is always evaluated first and the value will be assigned to the left hand side according to what i see. But, this doesn't happen right? The nature of the expression is ambigous(totally depends on how machine pretend it).
Expression, A[i] = i++. According to what I see, i will be incremented and that value will be assigned to the left hand side?
But these above expressions doesn't work the way i think they do. What is the possible way to write the expression so i don't get any kind of unexpected result specially caring about those increment or decrement operators.