To understand the array, first recognize the "address" in memory
I. Address
1. The memory in the computer is the storage space in bytes. Each byte of memory has a unique number, which is called an address. Every program and data stored in memory has an address, that is, a function has its own memory address.
2. When a variable is defined, the system allocates a storage unit with a unique address to store the variable.
3. During the commissioning process, we take a print view of the variable's address:
Ten; output address printf in 16 binary form ("16 binary:%x\n", &C); output address printf in 10 binary form ("10 binary:%d", &c);
Two. one-dimensional arrays
* The form of the definition is: type array name [number of elements]
int a[5];
[] inside is a fixed value, constant or constant expression, cannot be a variable, in most cases do not omit the number of elements (when the array is initialized as a function parameter and arrays)
When you define an array, the system allocates a contiguous amount of storage space by array type and number to store the array elements, such as int a[3], which occupies a contiguous 6 bytes of storage (in a 16-bit compiler environment, an int type occupies 2 bytes). Note that the array name represents the address of the entire array, which is the starting address of the array.
* Element Value list can be the initial value of all elements of an array, or it can be the initial value of an element in the preceding section
int a[4] = {5};
When an array is an integer, initialize an element with an indeterminate initial value, which defaults to 0, so the above a[2], a[3] are 0
* When assigning initial values to all array elements, you can omit the number of elements
int a[] = {7};
Indicates that the number of elements in array A is 3
* Array initialization can only be used for the definition of the array, after the definition can only one element of an element to assign a value
Two-dimensional array initialization, you can omit the number of rows, but you can not omit the number of columns.
Three. String
C language 03