1. Definition of arrays
An array is represented by a set of values, for example:
Char arr[10];
Arr is an array name, and a char is an array type. Indicates that there are 5 char types of data.
The meaning of an array is equivalent to arranging n variables of the same type.
2. Length of the array
The length of the array is specified in brackets and must be an integer constant.
such as: int arr[12];
You cannot use a variable to represent the length of an array. For example:
int size=12;
int att[size];
This writing is wrong.
3. Initial value of the array
You can specify an initial value for an element when you define an array.
Example: Char arr[5]={90,91,92,93,94};
Syntax requirements: Use a semicolon after curly braces, curly braces. Elements are separated by commas.
You can specify an initial value, or you can specify a partial initial value
4. Length of the array
Use sizeof to get the size of the array length
int arr [100];
int size=sizeof (arr);
5. Two-dimensional array
Type name [N][m];
6. Initialization of two-D arrays
int a[4][3]
{
{11,12,13},
{11,12,13},
{11,12,13},
{11,12,13},
}
C + + arrays