0

我遇到了内存访问冲突,我无法弄清楚。我猜我的语法在某处可能是错误的。这是我的代码

load(double **pDouble)
 {
   int size;

   //pStruct is returned by a method of some object inside load
   // arr is an array of double, also member of struct pointed by pStruct.
   size = sizeof(pStruct->arr)/sizeof(double);
   *pDouble =  new double[size];
   for(int i = 0 ; i < size; i++)
   {
     *pDouble[i] = pStruct->arr[i];
       //the violation occurs for the second iteration of 
      // the loop
   }
 }

什么可能导致访问冲突?

4

1 回答 1

1

数组索引比指针解引用绑定得更紧密。你可能的意思是:

(*pDouble)[i] = pStruct->arr[i];

不过可能还有其他错误。

于 2012-05-10T00:10:14.387 回答