Tuesday, September 20, 2005

Re: dynamic array


I think it is better to use the new and delete operator for the c++
dynamic allocation.

like
int row =3,col=3;
int **p = new int *[3];
for(int i=0;i<3;i++)
{
p[i]=new int[3];
}

now u can use p[i][j] notation for manuipulations
to delete the memory allocation

for(int i=0;i<3;i++)
{
delete [] p[i];
}

delete []p;

0 Comments:

Post a Comment

<< Home