C++数组指针,指针数组

来源:互联网 发布:行知社会实践园游后感 编辑:程序博客网 时间:2024/06/11 08:44

数组指针

#include <iostream>using namespace std;int main(){    int Test[2][3]={{1,2,3},{4,5,6}};    int (*A)[3];//A 为指向一个size为3的数组指针    A=&Test[1];//A 指向数组Test[1]:4,5,6    cout<<*A<<endl;//输出Test[1]地址,就是Test[1][0]地址    cout<<(*A)[0]<<(*A)[1]<<(*A)[2]<<endl;//输出456   system("pause"); }

指针数组

#include <iostream>using namespace std;int main(){    int Test[2][3]={{1,2,3},{4,5,6}};    int *p[2];    p[0]=Test[0];//p[0]=&Test[0][0]    p[1]=Test[1];//p[1]=&Test[1][0]    cout<<*p[0]<<endl;//1    cout<<*p[1]<<endl;//4    cout<<*(p[0]+1)<<endl;//2    system("pause"); }
0 0
原创粉丝点击