-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpointers7.cpp
54 lines (42 loc) · 1.15 KB
/
pointers7.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Pointers and Multi-Dimensional Arrays :
#include<iostream>
using namespace std;
int FuncA(int A[][3]) // for 2-d array
{
cout<<"print 2D array : "<<endl;
for(int i=0;i<2;i++)
{
for(int j=0;j<3;j++)
cout<<A[i][j]<<" ";
cout<<endl;
}
return 0;
}
int FuncB(int (*B)[2][2]) // for 3-d array
{
return 0;
}
int main()
{
int C[3][2][2] = {
{{2, 5}, {7, 9}},
{{3, 4}, {6, 1}},
{{0, 8}, {11, 13}}
};
cout<<C<<endl; // base-address of multidimensional array
cout<<*C<<endl; // base-address of multidimensional array
cout<<C[0]<<endl; // base-address of multidimensional array
cout<<C[0][0]<<endl; // base-address of multidimensional array
cout<<*(C[0][0]+1)<<endl; // print 5
// ***************************************************************
// multi-D arrays as function arg.
int A[2][3] = {{2,4,6}, {5,7,8}};
FuncA(A);
int B[2][2][2] = {
{{2,4}, {2,4}},
{{5,7}, {2,4}}
};
FuncA(A); // for 2-d array
FuncB(B);
return 0;
}