Reference: C + + Primer 5th edition
(1) 3.5.4 "C-style Character Strings"
(2) 3.5.1 "Character Arrays Are Special"
(3) 3.2.1 "Defining and Initializing ' string '"
(4) 2.1.3 "Character and Character String literals"
Several important concepts are:
1:string literal should be a "string constant" in Chinese, with an integer literal of this concept hierarchy, floating-point literal, character literal.
A character literal such as ' a ';
A string literal such as "Hello".
2:c-style character string is a convention, my understanding is a rule, it is not an entity.
C + + uses this Convention inherited from c as the standard when representing object of a string constant.
The Convention rule is that for a string literal, the compiler (compiler) should then add a null character (' ").
3: For the Convention of the C-style charater string, there is a corresponding operation C-style string function, in C + + these functions in the "CString" header.
4: You can use the character array to hold a string literal: (const) char a[] = "C + +";
You can also use a container string in C + + to hold it, by: string a = "C + +";
There are some differences between these two ways: it is particularly obvious that compiler will automatically add ' character ' at the end of string literal, while using string a = ' C + + ', when we supply a string literal, the characters from this literal-up to but not including the null character at the end of the literal-a Re copied into the newly created string "(that is, the right side of" C + + "is stored in the computer with a ' ', but string a =" C + + "; compiler only does not copy '").