4

when I tried std::cout << ', '; I got 11296, I know that I should've enclosed it with ", ", but why do I get the number?

demalegabi
  • 577
  • 6
  • 19

2 Answers2

3

You got two characters in single quotes (comma and space).
The value of such multicharacter literals depends on your compiler etc.

In this case, the ASCII values are 44 and 32, and

11296 = 44 * 256 + 32  

ie. both bytes together understood as 16bit integer

deviantfan
  • 11,268
  • 3
  • 32
  • 49
1

According to the standard (N4296, 2.13.3 Character literals, emphasis mine):

An ordinary character literal that contains more than one c-char is a multicharacter literal. A multicharacter literal, or an ordinary character literal containing a single c-char not representable in the execution character set, is conditionally-supported, has type int, and has an implementation-defined value.

"Conditionally-supported" is (1.3.5)

program construct that an implementation is not required to support

AlexD
  • 32,156
  • 3
  • 71
  • 65