1 #include <iostream>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <string.h>
5
6
7 using namespace std;
8
9 int main(){
10 cout<<"数组指针测试:--------"<<endl;
11 int (*p)[2];
12
13 int a[3][2]={{1,2},{3,4},{5,6}};
14
15 // p =&a[0];
16 p = a;
17
18 cout<<"p->:"<<p<<endl;
19 cout<<"a->:"<<a<<endl;
20
21 cout<<"(p+1)->:"<<(p+1)<<endl;
22 cout<<"a[1]->: "<<a[1]<<endl;
23
24 cout<<"a[1][1]->:"<<*(a[1]+1)<<endl;
25 cout<<"p[1][1]->:"<<*(*(p+1)+1)<<endl;
26
27 cout<<"p[0]->:"<<p[0]<<endl;
28 cout<<"a[0]->:"<<a[0]<<endl;
29
30 cout<<"a:" <<a<<endl;
31 cout<<"a[0]"<<a[0]<<endl;
32
33 cout<<"a+1"<<(a+1)<<endl;
34 cout<<"a[1]"<<a[1]<<endl;
35
36 cout<<"*(a+0)+0"<<(*(a+0)+0)<<endl;
37 cout<<"a[0][0]"<<&a[0][0]<<endl;
38
39 cout<<"*(a+1)"<<*(a+1)<<endl;
40 cout<<"a[1]"<<a[1]<<endl;
41
42 //p++;
43 /* for(int i = 0;i<2;i++){
44 cout<<p[0][i]<<endl;
45 }*/
46
47
48 cout<<"指针数组测试:------"<<endl;
49 int *c[3];
50 for(int i =0 ;i<3;i++){
51 c[i]=new int;
52 *c[i]= i;
53 }
54 for(int i = 0;i<3;i++){
55 cout<<"*c["<<i<<"]->"<<*c[i]<<endl;
56 delete c[i];
57 }
58
59
60
61 }