Hi, i've posted a message before but i didn't manage to allocate and free a pointer to pointer variable (matrix). I want to use it as Matrix[i][j] to manage better.
The first code I tried is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
double **pMatrix=newdouble*[N];
for(i=0;i<=N;i++)
{
pMatrix[i]=newdouble[N];
//I want a NxN square matrix
}
//now, are all elements 0? Do I have to inizialize them?
/////////////////////////////////
//I try to free memory
for(i=0;i<=N;i++)
{
delete []pMatrix[i];
//I suppose the error is in this line
}
delete []pMatrix;
I have also tried allocating with calloc.. let me show you the code
Can anybody help? if it is possible, please, would you write me the code correctly?
Ah, I use visual c++ 2008, but i don't think is a compiler's problem.