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
  • 69
  • 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
  • 227,678
  • 33
  • 352
  • 470