I must declare an array of arrays or multidimensional array without know the size. I want to do something similar that I do in this cases with simple arrays:
You're pretty much going to have to go with the loop version. You can make one slight improvement, which is to allocate one big block and then build your own int*
index into it:
int **array;
int *storage;
cin >> rows >> col;
array = new *int[rows];
storage = new int[rows*col];
for (int i = 0; i < rows; ++i)
array[i] = storage + col * i;
This has the nice property that you can still use array[i][j]
syntax for accessing the array.