Quote Originally Posted by Lindley View Post
Alternatives , each with slightly different properties:

Code:
//1
int **arr2d = new int*[rows];
for (i = 0; i < rows; i++)
    arr2d[i] = new int[cols];

//and release
for (i = 0; i < rows; i++)
    delete[] arr2d[i];
delete[] arr2d;

//2
std::vector< std::vector<int> > arr2d(rows, std::vector<int>(cols));
// no need to explicitly release

//3
std::vector<*int> arr2d(rows);
std::vector<int> arr2d_data(rows*cols);
for (i = 0; i < rows; i++)
    arr2d[i] = &arr2d_data[i*cols];
Alright Thanks! One more question, suppose I make a matrix by using an array "mat[4][5]" 4 rows and 5 columns and I wish to fill the matrix with random alphabets, how will I do that? Thanks!