CPP中二维数组做参数如何传入????
我需要写一个dll如下
#include "stdafx.h"#include <string.h>#include "myCorr_C.h"#include "mex.h"#define TESTAPI extern "C" __declspec( dllexport ) int _tmain(int argc, _TCHAR* argv[]){ return 0;}struct DataStruct{ double** data; double* qoe;};struct ContributionStruct{ double* contribution;};TESTAPI int init(){ if(!mycorr_CInitialize()){ return -1; }}TESTAPI ContributionStruct* qoc_add(DataStruct* dataStruct){ [color=#FF0000]dataStruct->data[0];//这里我需要从dataStruct中获取到data数组和qoe数组,并且还要将一个新的double数组写入到ContirbutionStruct中的contributin的double数组中,这里数组都是用指针来声明,没有用[],需要求助下,如何对这个DataStruct* 中的2个double数组进行取值赋值操作,比如获取到data数组的长度,一次获取到double数组中的每一个数等[/color] mxArray *argX=mxCreateDoubleMatrix(3,3,mxREAL); double data[9] ={-1.5,4,-3,1,2,2,2,3,8}; double qoe[3] = {3,5,6}; double contribution[3]; mxArray *argY=mxCreateDoubleMatrix(3,1,mxREAL); memcpy(mxGetPr(argX),data,9*sizeof(double)); memcpy(mxGetPr(argY),qoe,3*sizeof(double)); mxArray *coef = NULL; //memcpy(mxGetPr(X),x,9*sizeof(double)); mlfMycorr(1, &coef, argX, argY); double *resultP; resultP=mxGetPr(coef); for(int i=0;i<3;i++){ contribution[i]=*(resultP+i); } mxDestroyArray(argX); mxDestroyArray(argY); mxDestroyArray(coef); return 0;}TESTAPI int destroy(){ mycorr_CTerminate(); return 0;}