You posted an explanation of why that particular compiler produced the results, although you didn't distinguish between the implementation and the standard. A beginner might believe that the use of multiple operators with side effects in the same statement has defined behaviour when it doesn't or, worse, that it is a good idea.Why post nonsense when the correct answer has already been
posted to the list?
... i'm sure the answer i posted had no nonsense stuff in it.
The truth is that there is standard behaviour and nonstandard behaviour, and it is important in programming, which relies on accuracy, to distinguish between the two.and don't post answers until you know the truth.
... well...so what's the truth? can you kindly explain. you see am too novice to know the truth.
www.dictionary.com gives a good definition. Not defined (by the standard, although this is distinct from "not implemented by the compiler.") In context, it means that any behaviour of a statement containing multiple side effect operators is not to be relied on when porting the code to a different compiler (including a different version of the same compiler on the same platform). Also it means that questions on that statements behaviour cannot be answered by the standard, because the standard doesn't define that behaviour. So as far as the standard is concerned, x=a++ + a++; may assign 2a to x; it might assign a+a+1 to x; it might reformat your hard drive; it might even make the tea if you have appropriate hardware. It can be answered in the form of "this is how this particular compiler under these particular circumstances might treat this undefined sequence", but it can't be answered in terms fo the C programming Standard.In the meantime, repeat after me: the original program is
undefined and so there is no way of knowing what it "should" do. Undefined means undefined. ... undefined! what dya mean by undefined?