Two-dimensional arrays: two-dimensional arrays can be thought of as row-based, one-dimensional arrays.
Example: a[3][3]={{1,2,3},{4,5,6}.{ 7,8,9}} can be seen as being that the array is made up of three elements, each of which includes a one-dimensional array of three numbers.
Initialization of two-dimensional arrays
#include <stdio.h>
int main ()
{int p[3][3]={{1,2,3},{4,5,6},{7,8,9}};
int i=0,j=0;
for (i=0;i<3;i++)
{for (j=0;j<3;j++)
{printf ("%d", p[i][j]);
}
printf ("\ n");
}
return 0;}
2. Two-dimensional arrays as function parameters: two-dimensional arrays as function parameters, pass the address, the array of the two-dimensional array is an argument, representing the first element (including three data) of the first address.
#include <stdio.h>
void My_find (int (*p) [3])
{int i=0,j=0;
for (i=0;i<3;i++)
{for (j=0;j<3;j++)
{printf ("%d", p[i][j]);
}
printf ("\ n");
}
}
int main ()
{int p[3][3]={{1,2,3},{4,5,6},{7,8,9}};
My_find (P);
return 0;
}
This article is from the "local and static Variables" blog, reproduced please contact the author!
The application of two-dimensional array