請協助以下關於數組指針的問題。我有20個數組,每個數組長350個元素。我需要將20個數組中的3個地址傳遞給一個指針數組。 然後在我的代碼中,我需要訪問數組內的指針數組內的各個元素。但是我不確定語法,請評論下面的內容是否正確。將數組傳遞到C中的指針數組中
unsigned short Graph1[350];
unsigned short Graph2[350];
unsigned short Graph3[350];
... ... ...
unsigned short Graph19 [350];
unsigned short Graph20 [350];
unsigned short *ptr_Array[3];
...
*ptr_Array[0] = &Graph6; // Passing the address of array Graph6, into the array of pointers.
*ptr_Array[1] = &Graph11; // Passing the address of array Graph11, into the array of pointers.
*ptr_Array[2] = &Graph14; // Passing the address of array Graph14, into the array of pointers.
...
Varriable1 = *ptr_Array[1]+55 // Trying to pass the 55th element of Graph11 into Varriable1.
不是一個答案:'20個數組,每個350個元素'爲什麼你不使用二維數組? –
數組本身應該是一個指針,不是嗎? – Rolice
@Roice數組不是一個指針。如果用於表達式或作爲參數傳遞給函數,它會耗盡指針。 –