0

Why is this expression: int value = 0 if(++value == ++value) true?

Shouldn't that be equal to if(1 == 2) ? What is it equal to?

Corelation
  • 79
  • 7

1 Answers1

3

In c the value of the expression ++value == ++value is undefined. Technically, this is due to == not being a sequencing point..

Informally, this means that you don't know the order that evaluation of ++ and == will occur.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483