title: C++ fileIO line count
body: <pre><code>ifstream inFile;
  inFile.open(filename); //open the input file
  
  stringstream strStream;
  strStream &lt;&lt; inFile.rdbuf(); //read the file
  
  string str = strStream.str(); //str holds the content of the file
  </code></pre>
  
  <p>I am using this code to read from a file. I need to get the number of lines at that file. Is there a way of doing that without reading the file second time? </p>