title: C++ reading input from cin until the whole line has been read
body: <p>I have a while loop reading in a char 'c', I have a check to see if the the char is an operator; '+', '-', '/', or '*'. The while loop reads through character by character but it doesn't stop...if the last char inputed is '+' for example. It will stay in the loop with the char 'c' set to '+' forever.</p>
  
  <pre><code>stack&lt;int&gt; num;
  char c;
  int n,count=0,a,b;
  while (cin&gt;&gt;c)
  {
      if (c != '+' &amp;&amp; c != '-' &amp;&amp; c != '/' &amp;&amp; c != '*')
       {
           cout &lt;&lt; c &lt;&lt; endl;
           n = (c - 48);
           num.push(n);
           cin &gt;&gt; c;
           count++;
       }
       else if (c == '+' || c == '-' || c == '/' || c == '*')
       {
           cout &lt;&lt; "count is " &lt;&lt; count &lt;&lt; endl;
           if (count&gt;1)
           {
              b =  num.top();
              a = num.top();
              num.pop();
              num.pop();
  
              if (c == '+')
              {
                  num.push(a+b);
                  count--;
              }
              else if (c == '-')
              {
                  num.push(a+b);
                  count--;
              }
              else if (c == '/')
              {
                  if (b != 0)
                  {
                      num.push(a/b);
                      count--;
                  }
                  else
                  {
                      cout &lt;&lt; "division by zero" &lt;&lt; endl;
                      return(0);
                  }
              }
              else if (c == '*')
              {
                  num.push(a*b);
                  count--;
              }
              else
              {
                  cout &lt;&lt; "invalid input" &lt;&lt; endl;
                  return(0);          
              }
           }
           else
           {
               cout &lt;&lt; "stack underflow" &lt;&lt; c &lt;&lt; endl;
               return(0);
           }
       }
       cout &lt;&lt; c &lt;&lt; endl;
   }
  }
  </code></pre>