title: Reading piped input with C++
body: <p>I am using the following code:</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main(int argc, char **argv) {
      string lineInput = &quot; &quot;;
      while(lineInput.length()&gt;0) {
          cin &gt;&gt; lineInput;
          cout &lt;&lt; lineInput;
      }
      return 0;
  }
  </code></pre>
  <p>With the following command:
  <code>echo &quot;Hello&quot; | test.exe</code></p>
  <p>This result is an infinite loop printing &quot;Hello&quot;. How can I make it read and print a single &quot;Hello&quot;?</p>