0

char b = 'ABC DEF'; I know this is wrong but

char a = '(xx)'; where xx is a two digit number, why is this not wrong?

where cout << a; prints ) whatever the number is.

Asad Shakeel
  • 1,949
  • 1
  • 23
  • 29
  • 2
    Multi-char literals are *implementation defined*. What probably happens is that `'(xx)` is stored as an `int` (which is usually four bytes and therefore fits four one-byte characters) and the compiler simply truncates the upper bits and just assigns the low byte to the variable. – Some programmer dude Dec 20 '17 at 18:44
  • 1
    Nice dupe find. – Ron Dec 20 '17 at 18:46

0 Answers0