title: How to read input with c++ using program.exe < text.txt
body: <p>I have to read input according to these rules:</p>
  
  <blockquote>
    <p>"The input consists of several lines of text. Some lines may be empty. The input can be fed from a file, using a line such as <code>prog.exe &lt; input.txt</code> in which case the end of input is indicated appropriatelly by the operating system. If you enter input using a keyboard, there is normally a way to signal the end of input with some control key, depending on the operating system (e.g., <kbd>Ctrl+d</kbd> in Unix/Linux-style systems, and <kbd>Ctrl+z</kbd> in Microsoft systems)."</p>
  </blockquote>
  
  <p>Previously I have been doing it this way</p>
  
  <pre><code>while(getline(cin, data)) {
       if(data == "0") break;
       / * do stuff */
  }
  </code></pre>
  
  <p>So I can read as many lines as I want and preform calculations, and then when I'm done just type a 0 and end my program. I tried entering a list of things in a .txt file one per line, and then calling <code>program.exe &lt; myfile.txt</code> but nothing happened. </p>
  
  <p>What's this <code>&lt; file.txt</code> doing? </p>
  
  <p>How can I properly handle content inside it when calling my program like that?</p>
  
  <p>And how can I make it calculate things when you hit <kbd>ctrl</kbd>+<kbd>z</kbd>?</p>