title: fprintf prints a new line at the beginning of the file
body: <p>I'm using a fprintf function to print to a new file</p>
  
  <p>I'm using the following command to write multiple times:</p>
  
  <pre><code>fprintf(fp, "%-25s %d %.2f %d",temp-&gt;data.name, temp-&gt;data.day, temp-&gt;data.temp, temp-&gt;data.speed);
  </code></pre>
  
  <p>The problem is that sometimes the file gets an extra new line as the first character.
  Could this be lelftovers from some buffer, I don't really know...</p>
  
  <pre><code>typedef struct Data {
      char name[26];
      int day;
      int speed;
      float temp;
  } Data ;
  </code></pre>
  
  <p>@spatz you were right, I'm kind of new to the string format thing and I was told to make one for a fscanf where I was to expect an undetermined amount of space between the bits of data, here is what I came up with, I'm pretty sure its the source of the problem:</p>
  
  <pre><code>check=fscanf(fp1, "%20c%*[^0-9]%d%*[^0-9]%f%*[^0-9]%d%*[^\n]%*c", name, &amp;day, &amp;temp, &amp;speed);
  </code></pre>
  
  <p>only the first line get read normally and everything afterwards reads the new line of the previous line.</p>
  
  <p>Can someone please show me the proper way to write this thing?</p>