If the size of the array varies, you have to dynamically allocate the rows and columns:
Code:
//allocate 1D array of pointers, one pointer per row
a = (int **) calloc(row, sizeof(int *));
//allocate one column element array of ints for each row
for (i=0; i<row; ++i)
{
a[i]=(int *) calloc(column, sizeof(int));
//fill the matrix
for (i=0; i< row; ++i)
{
for (j=0; j<column; ++j)
a[i][j] = 2;
}
}
calloc fills the array with 0's automatically. You can have the user specify what the number of rows and columns is.
See if that helps.