(7.3)--7.3pointerandarray.pdf
《(7.3)--7.3pointerandarray.pdf》由会员分享,可在线阅读,更多相关《(7.3)--7.3pointerandarray.pdf(12页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Pointer and ArrayPointer and Array7.3After an array is defined,the system will allocate memory space with addresses for it.Pointer and Array7.3Givenint*p1;p1=a;Exampleint a4;After the array is defined,the system will allocate memory space with addresses for it,as shown in the figure below.Pointer an
2、d Array7.3Exampleint b22;After defining a two-dimensional array,the system will also allocate memory space for it.The elements in the two-dimensional array are stored in memory in a row-by-row manner,as shown in the following figure.Givenint*p2;p2=&b00;Pointer and Array7.3Assuming that p is a pointe
3、r and n is a positive integer,then p+n:the address of the n-th data after the address pointed to by p.p-n:the address of the n-th data before the address pointed to by p.Pointer ArithmeticPointer and Array7.3int main()int a=1,2,3,4,b22=5,6,7,8;int*p1=&a0,*p2=&b00;int i,j;for(i=0;i4;i+)cout“The start
4、ing address of ai“isp1+i,the data stored in it is*(p1+i)endl;for(i=0;i2;i+)for(j=0;j2;j+)cout“The starting address of bijisp2+i*2+j,the data stored in it is*(p2+i*2+j)endl;return 0;E.g.1Use pointer variables to manipulate arrays.Pointer and Array7.3In the above program,pointer variables p1 and p2 po
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 7.3 pointerandarray
限制150内