Seventh chapter array and string
A summary:
1. The array is a collection of the same type, the array elements of the same array have the same data type, the reference array is a reference to the elements of the array, the change of the subscript can refer to any element of the array, note that the subscript does not cross the reference, that will bring side effects.
2. Array type plays a very important role in data processing and numerical calculation, and the combination of arrays and loops can solve many problems.
3. The array can be categorized according to the number of subscripts: one-dimensional arrays (one subscript) ...
The 4.C language uses a character array to hold the string, which contains a ' + ' character that represents the end of the string.
B parsing:
7.1: Basic Concepts of arrays
: arranged in a certain order, with a set of variables of the same type of the same nature.
7.2.1: one-dimensional arrays
Form: Data type array name [integer constant expression];
A: The subscript is starting from 0
7.2. References to 21-D arrays
Form: array name [subscript expression]
Note: The subscript cannot be crossed.
7.2. Initialization of 31-D arrays
Form: Data type array name [integer constant expression]={Initial value 1, initial value 2 ...};
1:
int a[4];
A[0]=1;
a[1]=2;
a[2]=3;
a[3]=4;
2:
int a[4]={1,2}; /* Will a[0]=1, a[1]=2, other values default to 0*/
3:
int a[]={1,2,3}/* where subscript is specified as 3*/
7.2. Application of 41-dimensional arrays
7.3 Two-dimensional arrays
7.3.1 Definition:
Form: Data type array name [integer constant expression] [integer constant expression],..........
int A[2][3]/* The previous subscript represents the row, and the subscript represents the column */
7.3. References to 22-D arrays
Form: array name [row subscript expression] [column subscript expression]
7.3. Initialization of 32-D arrays
Form: Array name of data type [integer constant expression] [integer constant expression]={initialization data};
7.3. Application of 42-dimensional arrays
Student Achievement
7.4 Character array and string
1: The C language uses a character array to hold the string, which contains a ' + ' character that represents the end of the string.
2: Each element of a character array occupies one character. And each time the placeholder will be a bit more, because the end of ' s ' will be a character.
The seventh chapter of the Programming Basics array and string