title: Reading multi line inputs in C++
body: <p>I'm trying to read multiple lines of input from the command line in C++ and store them into an array. This is my code.</p>
  
  <pre><code>std::string line;
      int in;
      std::vector&lt;std::string&gt; v;
  
      while(std::getline(std::cin, line)){
          if(line == "^D") break;
          v.push_back(line);
      }
      for(auto it = v.begin(); it != v.end(); it++){
          std::cout&lt;&lt;*it&lt;&lt;std::endl;
  
      }
  </code></pre>
  
  <p>The stdin goes into an infinite loop and I can't seem to figure out how to prevent that. Basically the behavior targeted is that two consecutive press of enter without any input should terminate the stdin loop and run the program.</p>