I'm trying to make a dynamic 2-dimensional array.
Here is my code:
bool b_alloc_table_2_dim(int ***piTable, int iSizeX, int iSizeY)
{
*piTable = new int*[iSizeX];
for (int ii = 0; ii < iSizeX; ii++)
*piTable[ii] = new int[iSizeY]; // here i get the exception
return true;
}
int main()
{
int **x ;
b_alloc_table_2_dim( &x, 3, 5);
return 0;
}
I can't find anything wrong with the code. After calling my function x is supposed to point to the 2d array.