G
GraemeC
How can you determine the length of a dynamically created
multidimensional array?
Tried using sizeof unsuccesufully. It always returns 4, presumably
becuase I am using ints and it is just telling me the size of the
pointer myArray
Many thanks
G
int ** myArray = 0;
int Rows;
int Cols;
cout << "Number of Rows?" << endl;
cin >> Rows;
myArray = new int*[Rows];
for (int i_r = 0; i_r < Rows; i_r++)
{
cout << "Number of cols?" << endl;
cin >> Cols;
myArray[i_r] = new int[Cols];
for (int i_c=0; i_c < Cols; i_c++) {
cout << "Number" << i_c << endl;
cin >> myArray[i_r][i_c];
}
}
}
return 0;
}
multidimensional array?
Tried using sizeof unsuccesufully. It always returns 4, presumably
becuase I am using ints and it is just telling me the size of the
pointer myArray
Many thanks
G
int ** myArray = 0;
int Rows;
int Cols;
cout << "Number of Rows?" << endl;
cin >> Rows;
myArray = new int*[Rows];
for (int i_r = 0; i_r < Rows; i_r++)
{
cout << "Number of cols?" << endl;
cin >> Cols;
myArray[i_r] = new int[Cols];
for (int i_c=0; i_c < Cols; i_c++) {
cout << "Number" << i_c << endl;
cin >> myArray[i_r][i_c];
}
}
}
return 0;
}