title: How to skip blank lines when reading a file in c++?
body: <p>Ok, so here is the text of the file I am trying to read:</p>
  
  <pre><code>KEYS
  a set of keys
  3
  LAMP
  a brightly shining brass lamp
  8
  
  
  ROD
  a black rod with a rusty star
  12
  </code></pre>
  
  <hr>
  
  <p>Ok, so pretend that each line is evenly spaced, but there are 2 blank lines, (or tabs) between 8 and ROD. How would I skip that and continue with the program? I am trying to put each line into 3 vectors (so keys, lamp, and rod into one vector etc). Here is my code (but it does not skip the blank line).:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;vector&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  int main() {
      ifstream objFile;
      string inputName;
      string outputName;
      string header;
      cout &lt;&lt; "Enter image file name: "; 
      cin &gt;&gt; inputName;
      objFile.open(inputName);
      string name;
      vector&lt;string&gt; name2;
      string description;
      vector&lt;string&gt; description2;
      string initialLocation;
      vector&lt;string&gt; initialLocation2;
      string line;
  
  
      if(objFile) {
          while(!objFile.eof()){
                  getline(objFile, line);
                  name = line;
                  name2.push_back(name);
                  getline(objFile, line);
                  description = line;
                  description2.push_back(description);
                  getline(objFile, line);
                  initialLocation = line;
                  initialLocation2.push_back(initialLocation);
  
               } else {
          cout &lt;&lt; "not working" &lt;&lt; endl;
      }
  
      for (std::vector&lt;string&gt;::const_iterator i = name2.begin(); i != name2.end(); ++i)
         std::cout &lt;&lt; *i &lt;&lt; ' ';
     for (std::vector&lt;string&gt;::const_iterator i = description2.begin(); i != description2.end(); ++i)
         std::cout &lt;&lt; *i &lt;&lt; ' ';
      for (std::vector&lt;string&gt;::const_iterator i = initialLocation2.begin(); i != initialLocation2.end(); ++i)
          std::cout &lt;&lt; *i &lt;&lt; ' ';
  </code></pre>