title: Help with char input and printing in C++
body: <p>i want to read characters from the console and print them one after another only if they have a certain value.</p>
  
  <p>Well i tried using something like this:</p>
  
  <pre><code>char c;
  
  while (c != '\n') {
         c = getch();
         if (printable(c)) cout &lt;&lt; c; // where printable is a function which checks 
                                      // if the character is of a certain value
  }  
  </code></pre>
  
  <p>But this doesn't work as it prints all the characters, so any ideas what should i use?</p>
  
  <p>Thanks a lot!</p>
  
  <p><strong>Edit</strong>  </p>
  
  <p>Well i want to make polynomial calculator in which the user inputs the terms until pressed Enter, but if for example the user inputs 'r' or 'R' it will reset the input or 'q' and 'Q' to quit the program and also even if the user inputs illegall characters like '@',',',';', etc (also i don't want 'r' or 'q' printed) it won't print them on screen.</p>
  
  <p>Also here's the printable function:</p>
  
  <pre><code>bool printable(char c) 
      {
  
          return (
                    ((int(c) &gt; 42 &amp;&amp; int(c) &lt; 123) || isspace(c)) &amp;&amp; int(c) != 44 &amp;&amp; int(c) != 46 &amp;&amp; int(c) != 47 &amp;&amp; 
                    int(c) != 58 &amp;&amp; int(c) != 59 &amp;&amp; 
                    int(c) != 60 &amp;&amp; int(c) != 61 &amp;&amp; int(c) != 62 &amp;&amp; int(c) != 63 &amp;&amp; int(c) != 64 &amp;&amp; int(c) != 65 &amp;&amp; 
                    int(c) != 91 &amp;&amp; int(c) != 92 &amp;&amp; int(c) != 93 &amp;&amp; int(c) != 95 &amp;&amp; int(c) != 96
                  ); 
      }
  </code></pre>