title: About Ovewriting variables in scanf()
body: <p>I am creating a test program that shows an error message when an entered number is less than, or equal to, ten:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void errorMessage()
  {
     printf("\n This number is less than, or equal to, 10. Please try again. ");
  }
  
  int main()
  {
     int a;
     printf("\n Enter a number that is greater than 10. ");
     while(scanf(" %d",&amp;a) &lt;= 10)
     {
        errorMessage();
        printf("\n Enter a number that is greater than 10. ");
     }
     printf("\n This number is greater than 10.");
     return 0;
  }
  </code></pre>
  
  <p>The problem comes when a number less than, or equal to, ten (<em>e.g.</em> 5) is entered, then a number greater than ten (<em>e.g.</em> 15) is entered afterwards. The program executes <code>errorMessage()</code> even if the number makes the <code>while</code> statement false. I figured out that <code>scanf()</code> somehow stores the input value of <code>int a</code>. I wanna know how one would clear the input of <code>int a</code> before the program runs the <code>while</code> loop again.</p>