title: While loop to validate input is a number in C?
body: <p>So today I am trying to find a way to check if this input is a number. I cant find a way to make this code work so far. If I enter a number, the while loops ends, which is my intention. But, if I enter anything else, the code SHOULD print the printf once and then reprompt me for input (via the scanf statement back at the top of loop). But it instead prints the printf statement infinitely. How can I fix this?</p>
  
  <pre><code>float num1;
  while (scanf("%f",&amp;num1)==0)
      {
          printf("Invalid input. Please enter a number: ");
      }
  </code></pre>