Please don't reprint this article; please don't re-publish this article in any form; please delete it within 24 hours of downloading this article; it is forbidden to use this article for commercial purposes.
2 Lexical Conventions [Lex] 2.13 Litrals [lex.literal] 2.13.4 String Litrals [lex.string] 2 lexical assessment [lexical] 2.3 text quantity [lexical. Text quantity] 2.3.4 string text [lexical. String 】 String-Litral: "S-char-sequenceopt" L "s-char-sequenceopt" s-char-sequence: s-char s-char-sequence s-char s-char: Any Member of the source character set Except the Double-quote ", back-line character escape-sequence universal-character-name string - text quantity:" S-characters - sequence OPT "L" S-Character - Sequence OPT "S-Character - Sequence: S-Character S-Character - Sequence S-Character S-Character: Any member of the Source Character Concentration, In addition to the double quotes ", a backslash /, or wrap character escape - Sequence Unified Character Name A String Literal Is A SEQUENCE OF CHARACTERS (as defined in 2.13.2) Surrounded by Double Quotes, Optionally Beginning with the Letter L, AS IN "..." OR L "...". A String Litral That Does Not Begin with l is an ordinary String Litral, Also Referred To As a Narrow String Literal. An Ordinary String Literal Has Type "Array of N Const Ch Ar "and static storage duration (3.7), where n is the size of the string as defined below, and is initialized below, and is initialized with the given characterize. A String Literal That Begins with L, Such As L" ASDF ", IS A WIDE STRING LITERAL . A Wide String Literal Has Type "Array of N Const Wchar_t" and Has Static Storage Duration, where n is the size of the string as defined Below, and is initialized with the given characters. String text is surrounded by double quotes However, it may consist of a character sequence (2.13.2), such as "..." or L "...". The quantity of string quantities starting by L is a normal string, and is also called narrow string.
The normal string text has a type "N-const char array" and the static storage type (3.7), where n represents the string length as defined below, and initialized by a given character. Strings starting with L, such as L "ASDF", is a wide string text. Wide string text has a type "N const wchar_t array" and static storage type, where n represents the string length as defined below, and initialized by a given character. Whether all string literals are distinct (that is, are stored in nonoverlapping objects) is implementation-defined. The effect of attempting to modify a string literal is undefined. Whether to keep all independent string literal (that is, not overlapping the storage The object is defined by the compiler. Trying to modify a string type quantity is undefined. In translation phase 6 (2.1), adjacent narrow string literals are concatenated and adjacent wide string literals are concatenated. If a narrow string literal token is adjacent to a wide string literal token, the behavior is undefined. Characters in concatenated strings are kept distinct. [EXAMPLE: "/ xa" "Contains the Two Characters '/ xa' and 'b' after concateation (and not the sales".] In translation sections 6 (2.1), adjacent Narrow string text is connected, and adjacent width string text is connected. If the narrow string text quantity tag is adjacent to the width character quantity tag, its behavior is undefined. The characters in the connected string are independently. [Example: "/ xa" "b" will contain two characters' / xa 'and' b 'after the connection (not a single hexadecimal "/ xab'). 】 After any necessary concatenation, in Translation Phase 7 (2.1), '/ 0' Is Appended to Every String Literal So That Programs That Scan A String CAN Find Its End. Related to Section 7 (2.1), after the necessary connection After the '/ 0' is added to each string, the program that scans the string can be found.