title: C: Read from textfile into a struct array
body: <p>The program I am making is supposed to read in numbers from a text file and save the total number of numbers, the average value of the numbers in a struct.</p>
  
  <p>I have a struct that looks like this:</p>
  
  <pre><code>struct seriepost {
      int totnr;   
      int outnr;   
      float average;  
  };
  </code></pre>
  
  <p>And the function (unfinished) looks like this:</p>
  
  <pre><code>int read_data(FILE *tsin, struct seriepost serie[]) {   
  
          int x = 0;
          float average = 0;
          float in_last = 0;
          while (!feof(tsin))
          {
              while (fscanf(tsin, "%f", &amp;in_last) != 0.0)
              {
              serie[x].totnr += 1;
              serie[x].medel = average/serie[x].totnr;
              serie[x].outnr = average*1.05+average*0.95;
              }
              x += 1;
          }
          fclose(tsin);
          return sizeof(serie);
      }
  </code></pre>
  
  <p>The text file looks like this: </p>
  
  <pre><code>22.2 12.4 24.5 12.4..... 
  22.2 12.2 0.0
  
  2.21 12.1 11.1 11.1.... 
  1.1 0.0 
  </code></pre>
  
  <p>Where 0.0 marks the end of a series.</p>
  
  <p>Now i want the fscanf to read all the numbers until 0.0 then i want it to skip to the next array spot for the next series. So i have like serie[0], serie[1] with their own set of numbers and averages values etc.</p>