title: C program doesn't recognize '\n' in file exported from MATLAB
body: <p>I have a matrix <code>G</code> in MATLAB that I have printed into a text file using:</p>
  
  <pre><code>file = fopen('G.dat','w');
  fprintf(file, [repmat('%f\t', 1, size(G, 2)) '\n'], G'); 
  fclose(file);
  </code></pre>
  
  <p>The dimension of this matrix is 100 x 500. If I count rows and columns using awk, for instance, using </p>
  
  <pre><code>cat G.dat | awk '{print NF}END{print NR}' 
  </code></pre>
  
  <p>I see that the dimensions correspond to the original one.</p>
  
  <p>Now, I want to read this file, G.dat, from a C program that counts the columns of the first row just to understand the columns' dimension as in:     </p>
  
  <pre><code>    while (!feof(file) &amp;&amp; (fscanf(file, "%lf%c", &amp;k, &amp;c) == 2) ) {
          Ng++; 
          if (c == '\n') 
              break;
  }
  </code></pre>
  
  <p>Unfortunately it gives me Ng = 50000 and it doesn't recognize any of the '\n'.
  Instead, if I create the text file just by copying and pasting the data, it works. Can you explain me why? Thanks!</p>