Small string knowledge point (continuous update)
1. Differences between sizeof () and strlen () in calculating the length of a string
1> size of space occupied by string calculated by sizeof (); sizeof is commonly used to calculate the size of custom struct
2> the actual length of the string calculated by strlen (), but does not include the final string end flag '\ 0 '.
Example: Char A [20] = {"hello "};
Sizeof (A) = 20;
Strlen (A) = 5;
2. char s [] = {"123" "123"} is equivalent to Char s [] = {"123123"}. In the string, double quotation marks, other Symbols do not take effect or are empty. If you want to output other symbols, they must be combined with escape characters.
3. When processing strings, Use Pointer arrays instead of two-dimensional arrays. I will not talk much about the benefits. Let's take a look at the program below and
Char * test [] = {"tiger ",
"Welcome ",
"Tigerjibo ",
"Tigerjohn ",
};
Char test [4] [10] = {"tiger", "welcome", "tigerjibo", "tigerjohn "};