String: Must end with' \0'; // ? ' \0 '? It means "string terminator".
Character array: it can contain multiple' \0', but if it is treated as a string, the actually valid string is the signature string of the first' \0'; If it is treated as a character array, any character of the character array can be treated, and all characters can be' \0'.
2. Different characteristics
A string is similar to an array of characters in storage, so a single element of each bit can be extracted. For example, s = "abcdefghij ",then s [1] = "b" and s[9]="j ".
The zero position of the string is just its length, for example, s[0]= 10(※ The above function Ansistring is not available. ), can provide us with many conveniences, such as high-precision operation, each bit can be converted into a number and stored in an array.
Character array refers to an array used to store character data. The general form of its definition is: char array name [data length]. Character array is used to store characters or strings, and one element in the character array stores one character, occupying one byte of memory. C language has no string type, and strings are stored in character arrays.
Extended data:
Data type of string:
String data type is a data type modeled according to the idea of formal string. String is a very important and useful data type, which can be implemented in almost all programming languages.
In some languages, they can be obtained as basic types, while in other languages, they can be obtained as compound types. The syntax of most high-level languages allows strings that are usually referenced in some way to represent instances of string data types; This meta-string is called "text" or "string text".
Initialization of character array:
There is no essential difference between the initialization of character array and the initialization of numeric array. But it can not only assign characters to array elements one by one, but also initialize them directly with strings.
Initializes an array one by one with character constants. For example: char a[8]={'i',' l',' o',' v',' e',' y',' o',' u' };; Assign eight characters to eight elements c[0]~c[7] respectively.
Baidu Encyclopedia-Character Array
Baidu Encyclopedia-String