musbach
musbach

Reputation: 638

Bitwise operator in case statement

I do not understand the following c++ statement:

int c;
switch (c) {
  case 'a': ... ;
  case 'c' | 0x100: ... ;
  case 'c': ...;
}

What is the difference between case 'c' and case 'c' | 0x100? Isn't it the same and case 'c' is never reached?

Upvotes: 1

Views: 995

Answers (1)

Gabriel Cséfalvay
Gabriel Cséfalvay

Reputation: 539

No, those are two different numbers.

'c' equals to 0x063

'c'|0x100 equals to 0x163

Upvotes: 2

Related Questions