Pergunta

I'm getting a memory access violation which i am not able to figure out. I am guessing my syntax might be wrong somewhere. Here is my code

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
   }
 }

What could be causing the access violation?

Foi útil?

Solução

Array indexing binds more tightly than pointer dereferencing. You probably meant:

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

There may be other errors though.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top