C ++ std :: cout print wierd characters when I wrap a single quote string

When I tried std::cout << ', '; I received 11296 , I know I had to enclose it with a ", " , but why am I getting a number?

+4
source share
2 answers

You have two characters in single quotes (comma and space).
The meaning of such multi-character literals depends on your compiler, etc.

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

 11296 = 44 * 256 + 32 

i.e. both bytes are understood together as a 16-bit integer

+3
source

According to the standard ( N4296, 2.13.3 character literals , my attention):

a regular alphabetic character containing more than one c-char is a multi-channel literal. A multi -character literal or regular character literal containing a single c-char that cannot be represented in the set character is conditionally supported, is of type int, and has a value defined by the implementation .

"Conditionally supported" (1.3.5)

that implementation is not required to support

+1
source

All Articles