在C中,当我不知道数组的维数是什么时,我可以将多维数组作为单个参数传递给函数吗?
另外,我的多维数组可能包含除字符串以外的类型.
我有一个如下所示的程序:
double[4][4] startMatrix;
double[4][4] inverseMatrix;
initialize(startMatrix) //this puts the information I want in startMatrix
Run Code Online (Sandbox Code Playgroud)
我现在想要计算startMatrix的反转并将其放入inverseMatrix.我有一个用于此目的的库函数,其原型如下:
void MatrixInversion(double** A, int order, double** B)
Run Code Online (Sandbox Code Playgroud)
取A的倒数并将其放入B.问题是我需要知道如何将double [4] [4]转换为双**以赋予函数.我尝试过"明显的方式":
MatrixInversion((double**)startMatrix, 4, (double**)inverseMatrix))
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用.这实际上是正确的方法吗?