pointer of 2d array and address

1.int a;

(&a) can be used just like a pointer, with no doubt.

2.int a;

cout<<(&a)<<endl;

---------

Programme Run first,output:       0028FDF0;

Programme Run Second,output:    003FFED0;

 

This means that RAM allocates different storage address.

 

 

------------------

output:  003FFE9C

             003FFEA0

This indicates that size of one int cost 4 bytes. 

1 byte consists 8 bits.

 

4.

int arr[5]={1,2,3,4,5};
cout<<arr<<endl;
cout<<arr+1<<endl;//+1 not +1byte address, step +1 is +1 int_size, so +1 is overloading.
int* brr=arr+1;
cout<<brr[3]<<endl;

------------------

output:  003FFE9C

             003FFEA0

This indicates that size of one int cost 4 bytes. 

1 byte consists 8 bits.

+1 not +1byte address, step +1 is +1 int_size, so +1 is overloading.

 

 

5.

int dd[3][2]={1,2,3,4,5,6};
cout<<"&dd="<<&dd<<endl;
cout<<"(&dd)+1="<<(&dd)+1<<endl;

-----------------------------------

&dd=001FFD80;

(&dd)+1=001FFD98 // 24 bytes for one step.

 

6.

int dd[3][2]={1,2,3,4,5,6};
int ddd[3][2]={7,8,9,10,11,12};
cout<<"&dd="<<&dd<<endl;
cout<<"(&dd)+1="<<(&dd)+1<<endl;

cout<<"dd="<<dd<<endl;
cout<<"dd+1="<<dd+1<<endl;

 

--------------------------------

3
2
1
0038F8A0
0038F894
0038F888
0038F86C
0038F870
5
---------------------
&dd=0038F840
(&dd)+1=0038F858 //
dd=0038F840     // the same as above
dd+1=0038F848 // 8bytes jump, which is 2ints jump
请按任意键继续. . .

--------------------------------------------

 

&dd=0038F840 and  dd=0038F840   IS REALLY PUZZLING.

 =====================

 

Conclusion: 

1. Address has on address;

2. Address has a hierachy;

Hierachy means that step size of different address plus jumps different size.

3. Starting Address usually coincides.

 

posted @ 2016-08-10 11:54  steven_xiu  阅读(147)  评论(0编辑  收藏  举报