title: How to accept only integer values in C
body: <p>So I'm working on a C project which builds a pyramid and I need a little help. The program is to prompt the user for the pyramids height using an integer between 1-8 inclusive. If the users input does not cooperate with the prompt the program will re-prompt the user until they do so. So far I got the program to work however, there's a slit bug.  Whenever I type in a non integer the program runs an infinite loop. I just want to program to accept integers. HELP!!</p>
  
  <pre><code>int main(void)
  {
      int height;
      int dashes;
      printf("Height Please:\n");
      scanf("%d", &amp;height);
      while(height&lt;1 || height&gt;8){
          printf("Wrong input, try again\n");
          scanf("%d", &amp;height);
      } 
  
      for(int i=1;i&lt;=height;i++)
      {
          for(dashes=1;dashes&lt;=i;dashes++)
          {
          printf("#");
          }
          printf("\n");
  
      }
  
  }
  </code></pre>