All of your examples have undefined behaviour according to the C specification. Your compiler can give you whatever results it likes.
Carl Norum
2010-06-25 18:37:28
All of your examples have undefined behaviour according to the C specification. Your compiler can give you whatever results it likes.
Can anyone please explain me this. and also any good reference for brushing up C?
Modifying an l-value more than once between adjacent sequence points (roughly equivalent to statements) is an undefined operation. Your compiler is permitted to return any answer (including crashing, throwing an exception, etc.) and it will be correct according to the standard.
As for a reference on brushing up, K&R's is still pretty good.