簡體   English   中英

在 function (C) 中用作 arrays 的指針

[英]Pointers used as arrays in function (C)

test(int arr[])test(int *arr)是等價的表達式。

所以我想問什么適用於test(int **ar)

更新:

我需要調用主要的 function test(int *k,int **c) ,我無法理解從主要傳輸到測試的值。

例如,如果我有兩個 arrays K[3]C[24]並且我想使用這兩個作為參數,我會在 main 中調用test(K,C); 並且 function 將被聲明為void test(int k[ ],int c[ ]);

在這個例子中k[0]=K[0] , k[1]=K[1] , k[2]=K[2] , k[3]=K[3]c[0]=C[0] .. c[24]=C[24]

所以我想在 function test(int *k,int **c)中了解參數值會發生什么

引用N1570 6.7.6.3 Function 聲明符(包括原型):

7 將參數聲明為“類型數組”應調整為“限定類型指針”

int **ar是“指向int*的指針,因此“一個int*數組” int *ar[]將被調整為當它用作 function 參數時。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM