Hi I'm having some problem with 2D dynamic array.
int main()
{
double **M;
int M_dimension;
int i;
M_dimension = 10;
M = new double *[M_dimension];
for (i=0;i<M_dimension;i++)
{
M[i] = new double[M_dimension];
}
M[0][0] = 1.0;
...
}
Program works but I'd like to initialize 2D array using such a function:
void initialize2D(double **M,int M_dimension)
{
int i;
M = new double *[M_dimension];
for (i=0;i<M_dimension;i++)
{
M[i] = new double[M_dimension];
}
}
Finally the program looks like this:
int main()
{
double **M;
int M_dimension;
int i;
M_dimension = 10;
initialize2D(M,M_dimension);
M[0][0] = 1.0; //crash
...
}
Unfortunately it crashes at M[0][0] = 1.0;
Thanks for any help or suggestions.