I have said that there is only one dimensional array in C (this is my view of the array), and that the element can be any type of data (or object), or it can be another array (because the array is also a data type). So if you insist on having multidimensional arrays, that's not impossible. All we have to do is assign an array to the elements of another array. Of course, we have to make sure that the size of the array at the program compile time is a fixed constant.
In fact, the operation of the array is very simple. As long as we determine the size of an array and the pointer to the element labeled 0, any other array of subscript operations is equivalent to a corresponding pointer operation, so we say "arrays and pointers can interoperate". The essence of the two is the same. Even we can think of an array as a collection of "pointers."
I can declare an array in the following way:
char name[10];
This statement declares that name is an array of 10-character elements. Similar to
struct student{
int tid[4];
char name[10];
char sex;
char address[25];
} std[100];
This declares that an STD is an array of 100 elements, and that each element in the STD defines a student's basic information, each of which is a structure, including an array of 4 cosmetic elements (tid[4), which is used to record students ' learning There is also an array of 10 character elements (Name[10]) to record the student's name, a character to record the student's gender (sex), and an array (address[25) that records the student's address and has 25-character elements. Arrays are a very flexible structure.
The so-called "two-dimensional array" or "matrix" is very easy to declare, for example:
int week[7][24];
This declares the declaration week as an array of 7 elements of the array (so it doesn't feel like a spectacle), where each element is an array of 24 integer elements. Note that week cannot be understood as an array of 24 array elements, each of which is an array of 7 cosmetic elements. Also, if week is not the operand for the sizeof, it is always a pointer to the starting address of the week array. Here again with the needle in the running-in. If a pointer is to an element of an array, then we simply add a natural number I (the value of the upper boundary of the 0=<i < array), then we can get a pointer to the brother I element of the array. If you subtract 1 on this basis, you get a pointer to the previous element. This is a simple and flexible operation. But there is also a misconception: many people think that "adding an integer to a pointer is equivalent to adding a same integer to the pointer's binary number." In fact, this is a very easy to make mistakes, at least in the Beginner C language, I have made this mistake, and not only once. In fact, the meaning of the two is very different. Let's say we have one of these pointer declaration statements:
int *p;
So p is naturally a pointer to an integer, then p+1 points to the next integer in the computer's memory, rather than to the next memory location that points to the address. This means that the logical address of the program is generally different from the actual physical address.
If there are two elements pointing to the same array, then we can get some meaningful expressions from the arithmetic operations between the two pointers. Like what
int *pointer;
int *ip=pointer + i;