typedef struct{
int rows, cols; // matrix dimensions
int **element; // element array
}Matrix;
If i were to create a variable:
Matrix m;
How would i go about creating a 3x3 {{1,2,3},{4,5,6},{7,8,9}} array in the Matrix
?
Or for that matter, how could i store any sized two-dimensional array into m.element?
I have tried:
for (i=0; i<m.rows; i++)
{
for (k=0; k<m.cols; k++)
{
m.element=q;
q++;
}
}
Follow the advice of the comment and look at Dynamic Allocation of 2D Array
Then do
You need to add in the
m.element[i][j]
part to make it work.