title: fscanf line with condition
body: <p>my goal is to read in a data file consisting of just one number per line and write the data into a histogram. There are some comments in the file behind <code>#</code> characters. I want to skip these lines.</p>
  
  <p>I have started writing:</p>
  
  <pre><code>TH1F *hist = new TH1F("hist","",4096, -0.5,4095.5);
  //TF1 *fitfunc;
  
  char filename[100];
  double val;
  int i;
  char line[256];
  
  
  sprintf(filename,"test.dat");
  FILE* pfile = fopen(filename, "r");
  
  for (i=0;i&lt;=14;i++) {
      fgets(line,256,pfile);
      cout&lt;&lt;line&lt;&lt;endl;
      fscanf(pfile, "%lf /n", &amp;val);
      hist-&gt;SetBinContent(i,val);
  }
  </code></pre>
  
  <p>But only every other line gets written as "line" while the others are fscanfed.</p>
  
  <p>Would be very nice, if someone could give me a hint. </p>
  
  <p>...so this will obviously not work properly:</p>
  
  <pre><code>TH1F *hist = new TH1F("hist","",4096, -0.5,4095.5);
  //TF1 *fitfunc;
  
  char filename[100];
  double val;
  int i;
  char zeile[256];
  
  sprintf(filename,"test.dat");
  FILE* pfile = fopen(filename, "r");
  
  for (i=0;i&lt;=14;i++) 
  {
      fgets(zeile,256,pfile);
      cout&lt;&lt;"fgets: "&lt;&lt;zeile&lt;&lt;endl;
      if (zeile[0]!='#')
      {
          fscanf(pfile, "%lf /n", &amp;val);
          cout&lt;&lt;"val: "&lt;&lt;val&lt;&lt;endl;
          hist-&gt;SetBinContent(i,val);
      }
  }
  </code></pre>