title: C : How do you input integers row by row into a 2 dimensional matrix and then get it back from a function to main()?
body: <p>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.</p>
  
  <p>Quite new to C so apologies for the long read and terrible coding.</p>
  
  <p>This is for a homework hence why it has to be so specific but the homework reads as:</p>
  
  <p>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.</p>
  
  <p>So it needs to read in </p>
  
  <p>1 0 0</p>
  
  <p>1 0 0</p>
  
  <p>1 0 0</p>
  
  <p>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 </p>
  
  <pre><code>void matrix(int x, int y)
  {
      int i, j;
      char c;
  
      i = 0;
      j = 0;
  
      while (j &lt; x)
      {
          while (c != '\n')
          {
              scanf("%d%c", &amp;input[i][j], &amp;c);
          }
          ++j;
          c = 0;
      }
  }
  </code></pre>
  
  <p>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. </p>
  
  <p>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.</p>
  
  <p>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.</p>