title: Elements of matrix not being stored correctly after reading from a text file
body: <p>I am currently trying to read a matrix from a text file in c and I am trying to store the elements of the matrix in a 2D array in c.</p>
  
  <p>For example in a text file called "Matrix.txt" I currently have the following 3X16 matrix:</p>
  
  <pre><code>0   0   1   0   0   0   0   1   0   1   0   0   1   0   0   0   
  0   0   0   1   0   0   1   0   1   0   0   0   1   0   0   0   
  0   1   0   0   1   0   1   0   0   1   0   0   0   0   0   0   
  </code></pre>
  
  <p>I want to store the same exact matrix in c. The program that I implemented is below:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #define rows_Matrix 3
  #define cols_Matrix 16
  
  int main()
  {   
      unsigned **Matrix = (unsigned **)malloc(sizeof(unsigned *)*rows_Matrix); //Rows
  
      for (int i = 0; i &lt; rows_Matrix; i++) //Rows
      {
           Matrix[i] = (unsigned *)malloc(sizeof(unsigned) * cols_Matrix); //Columns 
      }
  
  FILE *file;
  file = fopen("Matrix.txt", "r");
  
      for (int i = 0; i &lt; rows_Matrix; i++)
      {
          for (int j = 0; j &lt; cols_Matrix; j++)
          {
              //Read elements from a text file. 
              if (!fscanf(file, "%d", &amp;Matrix[i][j]))
              {
                  break;
              }
  
          }
      }
  
           fclose(file);
  
           //Print Matrix.
           for (int i = 0; i &lt; rows_Matrix; i++) 
           {
              for (int j = 0; j &lt; cols_Matrix; j++)
              {
                  printf("%d\t", Matrix[i][j]);
              }
              printf("\n");
           }
  
  
      return 0;
  
  }
  </code></pre>
  
  <p>When the matrix is being stored and printed its as follows:</p>
  
  <pre><code> 0       0       1       0       0       0       0       1       0       1     0       0       1       0       0
  
   0
  
   0       0       0       1       0       0       1       0       1       0      0       0       1       0       0
  
   0
  
   0       1       0       0       1       0       1       0       0      1      0       0       0       0       0
  
   0
  </code></pre>
  
  <p>It should be stored and printed in this way:</p>
  
  <pre><code>   0    0   1   0   0   0   0   1   0   1   0   0   1   0   0   0   
     0    0   0   1   0   0   1   0   1   0   0   0   1   0   0   0   
     0    1   0   0   1   0   1   0   0   1   0   0   0   0   0   0   
  </code></pre>
  
  <p>I would truly appreciate knowing why the elements are not being stored correctly in the Matrix and I confirmed this when I did matrix multiplication. </p>