我想有一個函數,它執行以下操作:C:以引用的函數傳遞二維數組和如何使用它們裏面
int doFunction(int* nIndex)
{
//nIndex is a 2-D array of any size.
// I would like to fill this array inside this function.
//Eg: in nIndex[2][3], i would like to put 5.
}
int result;
int myIndex[5][6];
result = doFunction(myIndex);
可能有人請幫助我的兩件事情: 1 。是以上語法正確的函數定義,需要任意大小的二維數組? 2.當我將myIndex傳入函數時,語法正確嗎? 3.如何填充函數中的數組,或者如何訪問其字段?
感謝。
我敢肯定,這東西一式兩份。可能(http://stackoverflow.com/questions/404232/how-do-i-pass-a-reference-to-a-two-dimensional-array-to-a-function)(http://stackoverflow.com/questions/8659304/passing-two-dimensional-array-to-a-function-by-refrence-c-programming),(http://stackoverflow.com/questions/14548753/passing-a-multidimensional-variable-length數組功能)以及其他功能。 – phoeagon 2013-02-19 12:09:29