指针数组:array of pointers,即用于存储指针的数组,也就是数组元素都是指针。例如int *a[3];
数组指针:a pointer to an array,即指向数组的指针。例如 int (*b)[3];
具体使用场景如下:
1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 int x = 1, y = 2, z = 3; 7 int *a[3] = {&x, &y, &z}; 8 cout << *(a[0]) << " " << *(a[1]) << " " << *(a[2]) << endl; 9 int c[3] = {4,5,6}; 10 int (*b)[3] = &c; 11 cout << (*b)[0] << " " << (*b)[1] << " " << (*b)[2] << endl; 12 return 0; 13 }
输出如下: