title: Write a shell script that runs an program that requires input with cin
body: <p>In detail, I wrote a shell snippet, like this:</p>
  
  <pre><code>while read input
  do
    ./a.out
  done &lt; "$1"
  </code></pre>
  
  <p>"$1" is test file with several rows. Each row is one test case.</p>
  
  <p>a.out is compiled C++ file which my test cases run against.
  The C++ source code is like this:</p>
  
  <pre><code>while (1) {
    cout &lt;&lt; "Enter:\n"
    if ((cin &gt;&gt; v1) &amp;&amp; (cin &gt;&gt; v2)) {
      cout &lt;&lt; v1 &lt;&lt; "\n";
      cout &lt;&lt; v2 &lt;&lt; "\n";
    }
  }
  </code></pre>
  
  <p>We <strong>are not</strong> allowed to make a.out take parameters like this:
  ./a.out [parameters]</p>
  
  <p>For example, the test file contains two test cases:</p>
  
  <pre><code>"a b"
  "c d"
  </code></pre>
  
  <p>What I expect is, after running over my script,</p>
  
  <pre><code>a
  b
  c
  d
  </code></pre>
  
  <p>should be output. Thanks</p>