title: C reading file into 2D array
body: <p>I have file called input1.txt,which is a matrix of numbers and some letters.I am trying to read  and store it in a 2D array so that each charter will be 1 cell. Here is my text file:</p>
  
  <pre><code>1111S11110
  0000010001
  110100010d
  t001111110
  0100000001
  0111111101
  1111111101
  00000D01T1
  0111110001
  0000E01110
  </code></pre>
  
  <p>And here is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  
  // Function for finding the array length
  int numOfLines(FILE *const mazeFile){
      int c, count;
      count = 0;
      for( ;; ){
          c = fgetc(mazeFile);
          if( c == EOF || c == '\n' )
              break;
          ++count;
      }
      return count;
  }
  
  // Main Function
  int main( int argc, char **argv )
  {
      // Opening the Matrix File
      FILE *mazeFile;
      mazeFile = fopen( "input1.txt", "r" );
      if( mazeFile == NULL )
          return 1;
      int matrixSize = numOfLines( mazeFile );
  
      // Reading text file into 2D array
      int i,j;
      char mazeArray [matrixSize][matrixSize];
  
      for(i=0;i&lt;matrixSize;i++){
              for(j=0;j&lt;matrixSize;j++){
                  fscanf(mazeFile,"%c", &amp;mazeArray[i][j]);
              }
      }
  
      for(i=0;i&lt;matrixSize;i++){
          for(j=0;j&lt;matrixSize;j++){
              printf("%c",mazeArray[i][j]);
          }
      }
  
      fclose( mazeFile );
      return 0;
  }
  </code></pre>
  
  <p>However my console output is like that when i print them:</p>
  
  <pre><code>0000010001
  110100010d
  t001111110
  0100000001
  0111111101
  1111111101
  00000D01T1
  0111110001
  0000E01110@
  </code></pre>
  
  <p>Seems it does not read the 1st line,However in terms of indexes i think it is ok.I am new to C.Could anyone please help.Thanks in advance.</p>