I wrote this little code to test a 2 dimensional array. Given the array array[row][col] I can find total_columns, but I am at loss to figure out total_rows.
// 2 D array
#include <iostream>
using namespace std;
int main()
{
int row, col, total_columns;
// two dimensional array in the form array[row][col]
int iarray2[3][5] = { 1, 2, 3, 4, 5,
6, 7, 8, 9,10,
11,12,13,14,15 };
total_columns = sizeof(iarray2[0])/sizeof(int); // result = 5
//total_rows = ??;
for(row = 0; row < 3 ; row++)
{
for(col = 0; col < total_columns; col++)
{
cout << row << " " << col << " " << iarray2[row][col] << endl;
}
cout << endl;
}
// wait
cin.get();
return EXIT_SUCCESS;
}