array of pointers - array of pointers
I don't understand this question at all as an undergraduate. Recently, I took the time to figure it out.
simple explanation
Pointer array array of points The array is full of pointers
就像二维数组里面 每个二维数组的一维向量 其实都是一个指针 指向了其中的值
a pointer to an array a pointer to an array
code logic
Each element in a is the address of each element in arry
b is a pointer to the arry array, which stores the address of arry, which is the address of the first bit of arry
using namespace std;
int main() {
int arry[4] = {
1,2,3};
int* a[4]; //array of pointer;
int(*b)[4]; //a pointer to an array
b = &arry;
for (int i = 0; i < 4; ++i) {
a[i] = &(arry[i]);
}
cout << *(a[0])<<endl;
cout << (*b)[0]<<endl;
cout << (*b)[2]<<endl;
return 0;
}
operation result
think
If this is the case, the array pointer can be regarded as a two-dimensional array,
what about the pointer array? What is the use of int(*b)[4] to represent an array that can point to 4 different arrays of memory blocks