Edit: Ok returning the matrix bit is now ok but still can't get entering rows of values down. It still only gives one value.
Quite new to C so apologies for the long read and terrible coding.
This is for a homework hence why it has to be so specific but the homework reads as:
Prompt for the size of the multiplier, which may be no bigger than ten in either dimension. Read the elements by row, one row per line of input. If the actual input matrix has different number of row or column as specified in the former step, print an error message and end the program.
So it needs to read in
1 0 0
1 0 0
1 0 0
and see if thats the size as declared earlier. It needs to do this for two separate matrices hence why I'm using a function, and then it will multiply the two matrices. What I currently have is
void matrix(int x, int y)
{
int i, j;
char c;
i = 0;
j = 0;
while (j < x)
{
while (c != '\n')
{
scanf("%d%c", &input[i][j], &c);
}
++j;
c = 0;
}
}
Where x and y are the size of the matrix and input[10][10] is a global array which I'm using to transfer the values out of the function to main.
Is there a way to do this with pointers? I know there are ways of doing it but my problem is that cause its for a homework we can only use what we "know" so I can only use scanf to read in variables.
Another problem I'm having is reading in the row elements, it only accepts the last element I input (which it takes as the first element) and leaves the rest blank.