title: defensive programming on a menu. what type of input should I have?
body: <p>I tried to have defensive programming having input as an integer but the program would go into infinite loop if I entered a character.
  I then switched to having input as a character, but it does the loop twice. Once for the wrong character and once for the end of line keystroke.</p>
  
  <p>Is there any way to get the loop, just once?</p>
  
  <p>code:</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      char choice='5';
      while (choice != '1' &amp;&amp; choice !='2' &amp;&amp; choice !='3' &amp;&amp; choice!='4' &amp;&amp; choice!='0')
          {
               printf("Parakalw epilekste ena apo ta parakatw\n\n");
               printf("1.\tKafe 1.5 euro\n");
               printf("2.\tKafe me gala 1.8 euro\n");
               printf("3.\tSokolata 2.1euro\n");
               printf("4.\tSokolata me gala 2.4 euro\n");
               printf("0.\tExodos\n\n");
               printf("parakalw eisagete thn epilogh sas: ");
               scanf("%c",&amp;choice);
          }
  system("PAUSE");    
  return 0;
  }
  </code></pre>