Hi,
Thanks for all the replies. I took up iMalc's advice, sample code below if anyone needs it:
Code:
#include <iostream>
using namespace std;
int** initArray (int **b, const int numrows, const int numcols);
int main ()
{
int **c;
c = initArray(c, 3 , 3 );
int i, j = 0;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
cout << c[i][j] << " " ;
cout << endl;
}
//cout << c[2][2] << endl;
return (0);
}
int** initArray (int **array, const int numrows, const int numcols)
{
int i, j;
array = new int * [numrows];
cout << "Hello Hello" << endl;
for (i = 0; i < numrows; i++)
{
array[i] = new int [numcols];
cout << "Iteration " << i << endl;
}
for (i = 0; i < numrows; i++)
{
for (j = 0; j < numcols; j++)
{
array[i][j] = i*j;
cout << "I'm over here" << endl;
}
}
return array;
}
To hk_mp5kpdw:
Thanks for the solution , however I'm still not understanding the parameter in your modified function prototype as posted below:
Code:
void initArray (int ** &array, const int numrows, const int numcols)
Does this mean that there will be a pointer to a pointer of the address of array? Because when passing in a double pointer "c" (lets just say), I would assume that int ** &array would receive the address where c is pointing at. What is really throwing me off is why would you need the address of array?