![IOS學習筆記005--數(shù)組指針的概念及定義_第1頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/10/35bfc3d8-cc93-4769-a11f-ff4290b3e97b/35bfc3d8-cc93-4769-a11f-ff4290b3e97b1.gif)
![IOS學習筆記005--數(shù)組指針的概念及定義_第2頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/10/35bfc3d8-cc93-4769-a11f-ff4290b3e97b/35bfc3d8-cc93-4769-a11f-ff4290b3e97b2.gif)
![IOS學習筆記005--數(shù)組指針的概念及定義_第3頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/10/35bfc3d8-cc93-4769-a11f-ff4290b3e97b/35bfc3d8-cc93-4769-a11f-ff4290b3e97b3.gif)
![IOS學習筆記005--數(shù)組指針的概念及定義_第4頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/10/35bfc3d8-cc93-4769-a11f-ff4290b3e97b/35bfc3d8-cc93-4769-a11f-ff4290b3e97b4.gif)
![IOS學習筆記005--數(shù)組指針的概念及定義_第5頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/10/35bfc3d8-cc93-4769-a11f-ff4290b3e97b/35bfc3d8-cc93-4769-a11f-ff4290b3e97b5.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、ios學習筆記005數(shù)組指針的概念及定義ios learning notes 一 the concept and definition of array pointers1) array pointer: pointers to array elementsarray e1ement pointers:a variable addresses, an array con tai ning a number of elements, each array element has the corresponding address, pointer variable can point to an
2、 array element (to address a particular elements in a poi nter variable) in the so-called array el emen t pointer is the address of the array elementsyou can point to an array element with a pointer variableint a 10二1, 3, 5, 7, 9, 11, 13, 15, 17, 19:int * p;p 二& a 0;it's equivalent to int ti
3、mes p is equal to a;or an intequivalent to p = a;note: array a does not have an entire array of tables, representing the address of the first element of the array."p 二 a;z,the function of "is the address of the first element of an array to the pointer variable p" instead of ''
4、assigning the value of array a to p2) array pointers are initialized and useda, use pointers to reference array elementswhen the pointer points to the element, the operation is allowed:add an integer (with + or + =), such as p + 1subtract an integer (use -or -二),such as ptadd operations, such as p +
5、 +, + + pso the self-subtracting, like p -, ptwo pointers want to subtract, such as pp-p2 (which only makes sense when pl and p2 point to elements in the same array)b, pay attention to; if the initial value of p is & a 0, then p + i and a + i are the address of the array element a i, or they poi
6、nt to the element of an array the number i.the role of an array pointer: an element that indirectly accesses an array using array pointersthe definition of an array pointer: int * p;the initialization of the array poinlet: int a 4二1, 2, 3, 4;int * p 二 a; / / array pointer, which defines a pointer va
7、riable that points to the first address of array a (and the first address of the first element, a 0), and points to the first element of the arrayis equivalent to:int times p is equal to a, minus b, minus b.the array pointer accesses the array,s elements:a) p + 1 means the next element in the arrayb
8、) p-1 stands for the last element of the arrayconclusion:to reference an array element, you can use the following two methods:a) subscript: the form of a i.b) pointer method: * (a + i) or * (p + i)c) a is constant (a + + error), p is a variable (p + +),summary: for a one-dimensional arraya) obtain t
9、he address method of a i:a) & a i; / / take the address directlyb) a + i;0 p + i;b) the method of obtaining the value of a i:a) a i;b) * (a + i);c) * (p + i);(d)3) application: reverse arrayideas:/ / a pointer holds the n integers in array a in reverse order./ / take a 0 and a n - 1/ / note: a 叮
10、二 * (a + i);code:/ / an array in reverse ordervoid nixuarray (int a , int len) / / define an array pointerint * p 二 a;/ / define subscriptsint 1=0, j 二 len minus 1;int tempwhile (i < j) / / exchange a i and a jtemp = * (p + i);(p + i)二 * (p + j);(p + j)二 temp;/ / modify subscriptsj -;void main ()
11、int arr 10二1, 2, 3, 4, 5, 6, 7, 8, 9, 10;/ / the call function nixuarray ()nixuarray (arr 10);for (int 1=0; i < 10; i+) printf ( d t “, arr i);4) a one-dimensional pointer arraya, one-dimensional pointer arraythe element value of an array is a pointer array. a collection of ordered pointers in th
12、e pointer array. all elements of the pointer array must be a pointer variable with the same storage type and the same data type the general form of pointer array description is:type specification * array name array lengththe type specification is the type of variable that the pointer value points to
13、.such as:int * pa 4;the pa is an array of pointers, it has four array elements, each of which is a pointer to the integer variableb, the use of pointer arrays:int a = 3, b = 4, c 二 5;int * pa.arithmetic operation between pointer variables: operation is only possible between two pointer variables tha
14、t point to the same array, otherwise the operation is meaninglessa, two pointer variables, subtractthe difference between the two pointer variables is the number of elements that the two pointers point to between the array e 1 eme nts.in fact, the differenee between the two pointer values (the addre
15、ss) is divided by the length of the array element (bytes)arithmetic operation between b and pointer variablesthe subtraction between two pointerscommon usage: both pointers point to the same arrayi, determine whether the elements of the two pointer variables are contiguousii. determine a few element
16、s between two pointer variablesif two pointer variables point to the same element, they want to reduce the result to 0to determine whether the elements of two pointer variables are contiguous (continuously), they want to subtract the absolute value of 1the relationship between two pointerspl, >,
17、p returns 1, and pl is at the topthe return result is 0 and p is at the top or they point to the same locationc, note: there are only subtraction operations between twopointers, no addition, multiplication, and division6) use an array name to access the 2-d arraya, an array name is used to access th
18、e 2-d arrayint a 3 4二1, 3, 5, 7, 9, 1, 1, 13, 15, 17, 19, 21, 23;a stands for line 0, z,a + 1 stands for the first address, z,a + 2 is the first address of the second linea + i stands for the first line address of i.* (a + 1) is equal to &a 1 0_* (a + i) is the equivalent of a i 0_pointer:a 0 is
19、 equal to the first address of 0 / / first columna 0 + 1 = equals & a 0 1 / / the first address of the second columna 0 plus 2 is equal to the first address of the 0 2 / third columna 0 + i 二二 & a 0叮 / / the first address of the i column7) the 2-d array pointer is defined and initializeda, t
20、he two-dimensional array master points to the line, and it cannot directly assign the pointer variable to the following description:int a 3 4二1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, * p;the reason is that p is not the same thing as the object of a, or both. the c language can define array pointers by def
21、ining a pointer variable that has the same properties as a two-dimensional array namethe general form of a b and a two-dimensional array pointer variable is:data type (* pointer variable name) two-dimensional array column numberthe "type descriptor" is the data type for the referred array.
22、 the indicates the pointer type when the variable is nextc, if you want to assign a pointer to a 2-d array, you should do this:int a 3, 4;int (* p) 4; / / the statement is an array pointer that points to a one-dimensional array containing four elementsp 二 a; / / assign the first address of the two-d
23、imensional array to p, which is a 0 or a 0 0p+;/ / after the statement is executed, p 二 p + 1; p over a 0_ points to a 1so the array pointer also refers to the pointer to the one-dimensional array, also known as the line pointerd, 2-d array pointerthe line pointer, which is used to point to each row
24、 of the two-dimensional array, holds the first address of the rowformat:data type (* row pointer variable name) the length of the second dimension of the arrayinitialization of the 2d array pointerint a 2, 3;int b, 2, 2;float fl, 4, 4;/ / suppose you define a line pointer to an array a, which is as
25、follows:a, b, b, b, b, b, bit's going to be an intthe use of two dimensional array pointers * (p + i) + j; / / to get every element of the two-dimensionalarraythe code examples:void main () int a 3_it's goingfor (int ifor (int j4二1,to be an二 0; j3, 5,int.3; i4; j7, 9, 11, 13, 15,+ +) 17, 19, 21, 23.printf (“ d t , * (* p + i) + j);printf (“ n );/ / the output is:/ / 1 3 5 7 / 9 11 of 13 to 15 / / 17 19 and 238) the difference between pointer array an
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 無錫江蘇無錫市惠山區(qū)人民法院招聘編外人員3人筆試歷年參考題庫附帶答案詳解
- 2025至2031年中國鋁制滑輪行業(yè)投資前景及策略咨詢研究報告
- 2025至2031年中國蜂膠粉行業(yè)投資前景及策略咨詢研究報告
- 2025至2031年中國移動通訊運維分析集中管理平臺行業(yè)投資前景及策略咨詢研究報告
- 2025至2031年中國巧克力涂層糖行業(yè)投資前景及策略咨詢研究報告
- 2025至2031年中國多功能聯(lián)合訓練器行業(yè)投資前景及策略咨詢研究報告
- 2025年發(fā)泡專用酚醛樹脂項目可行性研究報告
- 2025至2031年中國2U電子節(jié)能燈行業(yè)投資前景及策略咨詢研究報告
- 2025至2030年高效去污粉項目投資價值分析報告
- 2025至2030年中國錐密封焊接式管接頭數(shù)據(jù)監(jiān)測研究報告
- GB/T 16475-1996變形鋁及鋁合金狀態(tài)代號
- GB 4706.20-2004家用和類似用途電器的安全滾筒式干衣機的特殊要求
- 無紙化會議系統(tǒng)解決方案
- 佛教空性與緣起課件
- 上海鐵路局勞動安全“八防”考試題庫(含答案)
- 《愿望的實現(xiàn)》教學設(shè)計
- 效率提升和品質(zhì)改善方案
- 中山大學抬頭信紙中山大學橫式便箋紙推薦信模板a
- 義務教育學科作業(yè)設(shè)計與管理指南
- 《汽車發(fā)展史》PPT課件(PPT 75頁)
- 常暗之廂(7規(guī)則-簡體修正)
評論
0/150
提交評論