Hey so I need to print out a matrix using malloc function. I have done that part and this is my code
int main (void)
int i = 0, j = 0;
//allocate space for 1 matrix
A = malloc(1 * sizeof (int *));
printf("Enter the number of rows and columns:");
printf("Enter the elements of the first matrix write 99 when done:");
if (A[i][j] == 99) // 'x' is character variable I declared to \
printf("The required matrix is\n");
So the catch is I don't want to ask the users seperately the number of rows and columns of a matrix. I want them to tell me at the same time they are telling me the matrix.
so I want the code to record the first 2 values (2,2) as the number of rows and columns and then print out the rest of the matrix.
printf("What is your matrix")
(user) 2 2 1 2 3 4
The only thing confusing me about this is how I am supposed to allocate space for a matrix I don't know the dimensions of