user-0 提问: 高手请看，C语言中这个东西的意义是什么？

回复:
user: user-1

user: user-2
content: 就是给C语言考试增加一个没实际用处的考点

user: user-0
content: 好吧，既然是多字符常量的实现依赖编译器的实现，那就不用它了。 果然是门万能的语言，细节学不完，呵呵

user: user-3
content: 引用 15 楼 WizardOz 的回复:你确定C语言中的字符串可以用单引号？ 好吧我承认我错了，我收回上一个回复

user: user-3
content: 你确定C语言中的字符串可以用单引号？

user: user-4
content: 由便咦气（编译器）截断处理

user: user-5
content: 引用 9 楼 mymtom 的回复:[quote=引用 7 楼 sholber 的回复:] [quote=引用 3 楼 mymtom 的回复:] 不要这么写，因为结果是不确定的。  3.1.3.4 Character constants ....  Semantics     An integer character constant has type int.  The value of an integer character constant containing a single character that maps into a member of the basic execution character set is the numerical value of the representation of the mapped character interpreted as an integer.  The value of an integer character constant containing more than one character, or containing a character or escape sequence not represented in the basic execution character set, is implementation-defined.  In particular, in an implementation in which type char has the same range of values as signed char, the high-order bit position of a single-character integer character constant is treated as a sign bit.  如果不让这么写，那么 wchar_t wc = '嗨'; 也不应该写，因为这同样是实现定义的。 你只看到'ab'是more than one character， 但你忘了， '嗨'同样是more than one character.[/quote] wchar_t wc = '嗨'; 这个写法本来就有问题[/quote]  什么问题？

user: user-6
content: 引用 7 楼 sholber 的回复:[quote=引用 3 楼 mymtom 的回复:] 不要这么写，因为结果是不确定的。  3.1.3.4 Character constants ....  Semantics     An integer character constant has type int.  The value of an integer character constant containing a single character that maps into a member of the basic execution character set is the numerical value of the representation of the mapped character interpreted as an integer.  The value of an integer character constant containing more than one character, or containing a character or escape sequence not represented in the basic execution character set, is implementation-defined.  In particular, in an implementation in which type char has the same range of values as signed char, the high-order bit position of a single-character integer character constant is treated as a sign bit.  如果不让这么写，那么 wchar_t wc = '嗨'; 也不应该写，因为这同样是实现定义的。 你只看到'ab'是more than one character， 但你忘了， '嗨'同样是more than one character.[/quote] wchar_t wc = '嗨'; 这个写法本来就有问题

user: user-7
content: C++ Character Constants Character constants are one or more members of the “source character set,” the character set in which a program is written, surrounded by single quotation marks ('). They are used to represent characters in the “execution character set,” the character set on the machine where the program executes.  Microsoft Specific   For Microsoft C++, the source and execution character sets are both ASCII.  END Microsoft Specific  There are three kinds of character constants:   Normal character constants   Multicharacter constants   Wide-character constants  Note   Use wide-character constants in place of multicharacter constants to ensure portability.  Character constants are specified as one or more characters enclosed in single quotation marks. For example:  char ch = 'x';          // Specify normal character constant. int mbch = 'ab';        // Specify system-dependent                         //  multicharacter constant. wchar_t wcch = L'ab';   // Specify wide-character constant.  Note that mbch is of type int. If it were declared as type char, the second byte would not be retained. A multicharacter constant has four meaningful characters; specifying more than four generates an error message.  Syntax  character-constant :  'c-char-sequence' L'c-char-sequence'  c-char-sequence :  c-char c-char-sequence c-char  c-char :  any member of the source character set except the single quotation mark ('), backslash (\), or newline character escape-sequence  escape-sequence :  simple-escape-sequence octal-escape-sequence hexadecimal-escape-sequence  simple-escape-sequence : one of  \' \" \? \\ \a \b \f \n \r \t \v  octal-escape-sequence :  \octal-digit \octal-digit octal-digit \octal-digit octal-digit octal-digit  hexadecimal-escape-sequence :  \xhexadecimal-digit hexadecimal-escape-sequence hexadecimal-digit  Microsoft C++ supports normal, multicharacter, and wide-character constants. Use wide-character constants to specify members of the extended execution character set (for example, to support an international application). Normal character constants have type char, multicharacter constants have type int, and wide-character constants have type wchar_t. (The type wchar_t is defined in the standard include files STDDEF.H, STDLIB.H, and STRING.H. The wide-character functions, however, are prototyped only in STDLIB.H.)  The only difference in specification between normal and wide-character constants is that wide-character constants are preceded by the letter L. For example:  char schar = 'x';               // Normal character constant wchar_t wchar = L'\x81\x19';    // Wide-character constant  Table 1.2 shows reserved or nongraphic characters that are system dependent or not allowed within character constants. These characters should be represented with escape sequences.  Table 1.2   C++ Reserved or Nongraphic Characters  Character ASCII  Representation ASCII  Value Escape Sequence  Newline NL (LF) 10 or 0x0a \n  Horizontal tab HT 9 \t  Vertical tab VT 11 or 0x0b \v  Backspace BS 8 \b  Carriage return CR 13 or 0x0d \r  Formfeed FF 12 or 0x0c \f  Alert BEL 7 \a  Backslash \ 92 or 0x5c \\  Question mark ? 63 or 0x3f \?  Single quotation mark ' 39 or 0x27 \'  Double quotation mark " 34 or 0x22 \"  Octal number ooo — \ooo  Hexadecimal number hhh — \xhhh  Null character NUL 0 \0    If the character following the backslash does not specify a legal escape sequence, the result is implementation defined. In Microsoft C++, the character following the backslash is taken literally, as though the escape were not present, and a level 1 warning (“unrecognized character escape sequence”) is issued.  Octal escape sequences, specified in the form \ooo, consist of a backslash and one, two, or three octal characters. Hexadecimal escape sequences, specified in the form \xhhh, consist of the characters \x followed by a sequence of hexadecimal digits. Unlike octal escape constants, there is no limit on the number of hexadecimal digits in an escape sequence.  Octal escape sequences are terminated by the first character that is not an octal digit, or when three characters are seen. For example:  wchar_t och = L'\076a';  // Sequence terminates at a char    ch = '\233';     // Sequence terminates after 3 characters  Similarly, hexadecimal escape sequences terminate at the first character that is not a hexadecimal digit. Because hexadecimal digits include the letters a through f (and A through F), make sure the escape sequence terminates at the intended digit.  Because the single quotation mark (') encloses character constants, use the escape sequence \' to represent enclosed single quotation marks. The double quotation mark (") can be represented without an escape sequence. The backslash character (\) is a line-continuation character when placed at the end of a line. If you want a backslash character to appear within a character constant, you must type two backslashes in a row (\\). (SeePhases of Translation in the Preprocessor Reference for more information about line continuation.)

user: user-5
content: 引用 3 楼 mymtom 的回复:不要这么写，因为结果是不确定的。  3.1.3.4 Character constants ....  Semantics     An integer character constant has type int.  The value of an integer character constant containing a single character that maps into a member of the basic execution character set is the numerical value of the representation of the mapped character interpreted as an integer.  The value of an integer character constant containing more than one character, or containing a character or escape sequence not represented in the basic execution character set, is implementation-defined.  In particular, in an implementation in which type char has the same range of values as signed char, the high-order bit position of a single-character integer character constant is treated as a sign bit.  如果不让这么写，那么 wchar_t wc = '嗨'; 也不应该写，因为这同样是实现定义的。 你只看到'ab'是more than one character， 但你忘了， '嗨'同样是more than one character.

user: user-5
content: 引用 2 楼 jiht594 的回复:你觉得''里面放2-4个字符对吗?谁告诉你这么写的?  C标准告诉我们这么写的。

user: user-8
content: %x默认是最4个字节来格式化成16进制显示.  单引号里面是放一个字符.  你的写法要看到为什么这么显示, 你可以查看反汇编, 就清楚了.

user: user-0
content: 引用 2 楼 jiht594 的回复:你觉得''里面放2-4个字符对吗?谁告诉你这么写的? 既然编译器支持，就说明这是对的。我也是在群里看到大家讨论才来测试的，以为是C的偏门语法，但用下来感觉这样用很不靠谱啊。 char a = 'ab'; //编译器给警告，从int截断为char，而不是错误 我只是想，既然编译器支持肯定有它的用处，只是不知用在何处，特来问问

user: user-6
content: 不要这么写，因为结果是不确定的。  3.1.3.4 Character constants ....  Semantics     An integer character constant has type int.  The value of an integer character constant containing a single character that maps into a member of the basic execution character set is the numerical value of the representation of the mapped character interpreted as an integer.  The value of an integer character constant containing more than one character, or containing a character or escape sequence not represented in the basic execution character set, is implementation-defined.  In particular, in an implementation in which type char has the same range of values as signed char, the high-order bit position of a single-character integer character constant is treated as a sign bit.

user: user-5
content: 引用 11 楼 my_live_123 的回复:由便咦气（编译器）截断处理  是便一起。

user: user-9
content: 你觉得''里面放2-4个字符对吗?谁告诉你这么写的?

user: user-10
content: 看不懂你想说什么