1. Determining the size of a two-dimensional array
void Func (int array[3][10]);
void Func (int array[][10]);
2. Two-dimensional arrays of indeterminate size are converted to two-dimensional pointers:
Arguments are passed to the starting address of the array, stored in memory by array rules (stored in rows), and not by branches and columns, so it can be converted to a two-dimensional pointer.
void Func (int **array, int m, int n);
Call to convert the array name to a two-dimensional pointer
Func ((int**) A, 3, 3);
Get specific array elements
* ((int*) array + n*i + j);
: Where (int *) array converts an array to the storage of one-dimensional arrays
The elements are then read from a one-dimensional array.
If * (array + n*i + j); Output:
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
00000009
0000000A
0000000B
0000000C
0000000D
0000000E
0000000F
00000010
If * ((int*) array + n*i + j); Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
3. The most convenient is to switch to one-dimensional pointers.
Because it is stored continuously in memory, so ...
void Func (int *array, int m, int n);
Call to convert the array name to a two-dimensional pointer
Func ((int*) A, 3, 3);
Get specific array elements
* (array + n*i + j);
Basic knowledge of C + +--two-D array for function parameters