title: How do I fix scanf? (FailSafes)
body: <p>Here i have a simplified piece of code that asks and displays a number on a loop, it works fine for all numbers i type in, But if i input a letter or a special character (!"£$%^&amp;*-_=+ etc ) it goes mental and skips the input.</p>
  
  <pre><code> #include&lt;stdio.h&gt;
  
   int number; 
   int main()
   {
       do
       {
       system("cls");
       printf("Enter a number");
       scanf("%d",&amp;number);
       }
       while(1==1);
  }
  </code></pre>
  
  <p>My question is, what can i do to stop this from happening?, is there some code that filters out this nonsense or is scanf pretty much worthless?</p>
  
  <p>//Edit: This is somehow been marked as a duplicate, heh.</p>