accessing dynamic 2D array

Hi guys,

Iam creating this 2D array dynamically like this

array = new int *[height];
for(int i = 0; i < height; i++)
{
array[i] = new int[width];
}
fillArray(&array);


and then Iam trying to change all values within to 0, but this is just not working...

void Lode::fillArray(int ***array)
{
for(int i = 0; i < height; i++)
{
for(int j = 0; j < width; j++)
{
array[i][j] = 0;
}
}
}


Can someone please tell me where is a mistake? I have been working with pointers only for a few days.. :o)
Last edited on
You need to pass it simply as array, without the address-of operator. Then accept it in fillArray like int **array.
Thanks very much.. its working.
Last edited on
Topic archived. No new replies allowed.