3rd chapter strings, Vectors and arrays
1. How do I read a whole line of content with a string?
You can use Getline (cin,s). Of course getline () can also be used as a while loop to read input judgment conditions.
2. String literals and literal values of strings are added
Since the + method is left-to-right, so long as the two values are guaranteed to be added, at least one of the two sides of the + sign is a string on the line.
3. String can be added not only to the string literal, but also to An array of strings that end with the ' + ' character .
4. Note the initial value of the following array:
If both A and B arrays are global:
5. Complex array declarations
6. Note the operation of the following pointers:
7. Note the following two different output results:
Because STR actually points to a string constant array in string s, the contents of STR change naturally if the contents of the array are changed. So look at the following results:
Why does it still output ABCDE? Because the original string array can only hold 5 characters, now the new string has 6 characters, then the string class will request a new large enough space to re-save "ABCDEF", and the previous character array str content is unchanged, so if we also output str, is actually outputting the contents of the old string array.
8. How to initialize vectors with arrays in c++11
9. Multidimensional arrays in C + + are just arrays of arrays
When auto and Decltype infer an array name, the result is different:
Auto infers a pointer type , and Decltype infers an array type .
C + + Primer Learning Summary 3rd Chapter string, vector and array