int *p[]是一个存数组的指针,其中的元素是指针,要对元素所指的位置调用需要二阶调用
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int a[10][6], * p[10];
    for (int i = 0; i < 10; ++i)
        for (int j = 0; j < 6; ++j)
            a[i][j] = i + j;
    for (int i = 0; i < 10; ++i)
    {
        p[i] = &a[i][0];
    }
a[1][2]=1;
//也可以用p[i][j]来访问 cout
<< *(p[1] + 2) << endl;//输出1 cout << **(p+2) << endl;//输出2,是p[2][0]
cout << *(* (p + 2)+2)  << endl;//输出4,是p[2][2] cout
<< p << endl;//输出指针的地址
cout << &a[1][0] << endl; cout
<< p[1] << endl;//输出指针所指地址 return 0; }

 

 posted on 2022-12-02 08:44  ruoye123456  阅读(317)  评论(0编辑  收藏  举报