博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
pointer of 2d array and address
阅读量:5223 次
发布时间:2019-06-14

本文共 1650 字,大约阅读时间需要 5 分钟。

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.

 

转载于:https://www.cnblogs.com/stevenxiu/p/5756188.html

你可能感兴趣的文章
quartz 实现调度任务 SchedulerManager
查看>>
new jordans 9 Nets
查看>>
CSS3伪类:target
查看>>
hadoop SecondaryNameNode和NameNode
查看>>
VS2015安装开发ios android
查看>>
网站构建
查看>>
[翻译] FastReport "Text" 对象中使用表达式
查看>>
redis哨兵集群、docker入门
查看>>
laravel学习笔记(三)视图渲染
查看>>
rmdir
查看>>
SGU 219 Synchrograph tarjian找环,理解题意,图论 难度:3
查看>>
[翻译][架构设计]The Clean Architecture
查看>>
状态压缩DP
查看>>
Shell从入门到精通进阶之四:流程控制
查看>>
腾讯QQ、新浪微博等知名社交网络图标素材
查看>>
Django中用 form 实现登录注册
查看>>
关于__int64的使用!
查看>>
msil指令 收藏
查看>>
JS08(封装可视区域大小的函数、修改窗口改变页面颜色、冒泡的问题、弹出窗口点击空白处隐藏 、选定文字弹出层、动画基本原理、匀速动画封装函数、无限广告轮播图)...
查看>>
理解session
查看>>