程序编译通过,在执行时出现Unhandled exception in MyProject.exe(MSVCRTD.DLL) 0xc0000005:Access violation。请各位高手指点!         int len0 = m_prToothPointsVertexList[0].size();
double **pPoints0;
         pPoints0 = new double*[len0];
for(int i0 = 0 ; i0 < len0; i0++)
{
pPoints0[i0] = new double[3];
for(int j = 0 ; j < 3 ; j++)
{
pPoints0[i0][j] = 0.0;
}
} mxArray *matrix0 = mxCreateDoubleMatrix(len0, 3, mxREAL);
double *pr0 = mxGetPr(matrix0);
//拷贝数据,从C格式数组→mxArray
memcpy(pr0, pPoints0, 3*len0*sizeof(double));程序在memcpy这里出现异常。

解决方案 »

  1.   

    memcpy(pr0, pPoints0, 3*len0*sizeof(double));//pr0为double *,pPoints0为double **类型当然会出错。
    我做过测试代码改成如下没错,数据也正确。
    int len0 = 10;
    double** pPoints0;
    pPoints0 = new double*[len0];
    for(int i0 = 0 ; i0 < len0; i0++)
    {
    pPoints0[i0] = new double[3];
    for(int j = 0 ; j < 3 ; j++)
    {
    pPoints0[i0][j] = 1.0;
    }
    }
    double** pr0;
    pr0 = new double*[len0];
    //拷贝数据,从C格式数组→mxArray
    memcpy(pr0, pPoints0, 3*len0*sizeof(double));
    double db=pr0[9][2];