title: How to exit a program when user inputs a special character
body: <p>i'm curently doing a simple program that consists of a while-loop that reads in two ints and then prints them out. My question is, how can I exit the program when the user inputs the caracter "|"? Here is this little super simple program:</p>
  
  <pre><code>int main()
  {
      int var1 = 0;
      int var2 = 0;
  
      while(cin&gt;&gt;var1&gt;&gt;var2)
      {
          cout &lt;&lt; var1 &lt;&lt; " " &lt;&lt; var2 &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I know that you can define an argument to getline that does exactly what I want to do, but I don't know how to implement this in a while-loop. Thanks for the help.</p>