title: How to skip the header line in a text file and read back the rest of the data to the main function?
body: <p>I'm just learning about <strong>text file input/output</strong>. I have outputted a file which contains a header and 10 rows of data underneath it.
  I now want to read this back to the main function. This works for me if I leave out the header in the text file, but if I leave the header in, I get an infinite loop.
  <strong>How can I skip the 1st line (the header line) in reading this data back, or if possible, read back the header as well as the data?</strong>
  Here is what I have so far:</p>
  
  <pre><code>void fileRead(int x2[], double y2[], int&amp; n, char filename)
  {
       ifstream fin ("pendulum.txt"); // fin is an input file stream
  
       if(!fin) //same as fin.fail()
       {
                cerr &lt;&lt; "Failure to open pendulum.txt for input" &lt;&lt; endl;
                exit(1);
       }
  
       int j = 0, dummy = 0; //index of the first value j and dummy  value
       while(!fin.eof()) //loop while not end of file
       {
             fin &gt;&gt; dummy &gt;&gt; x2[j] &gt;&gt; y2[j];
             cout &lt;&lt; setw(5) &lt;&lt; fixed &lt;&lt; j
                  &lt;&lt; setw(12) &lt;&lt; scientific &lt;&lt; x2[j] &lt;&lt; "   "
                  &lt;&lt; setw(12) &lt;&lt; y2[j] &lt;&lt; endl; //print a copy on screen
             j += 1;           
       }
  
       fin.close(); //close the input file
  
  }
  </code></pre>