title: scanf validate user input
body: <p>I need to write a program in pure <code>C</code>. I wish to fill an array with user inputted floats and my function at the moment looks like this:</p>
  
  <pre><code>int fillWithCustom(float *array, int size) {
      float customNumber;
      for (i = 0; i &lt; size; i++)
          for (j = 0; j &lt; size; j++) {            
              printf("\n Enter [%d][%d] element: ", i , j);
              scanf("%f", &amp;customNumber);
              *(array+i*size+j) = customNumber;
          }
      return 1;
  }
  </code></pre>
  
  <p>But when I enter wrong number or char, iteration continues to an end...(Ex. I enter "a" as first element, then both for cycles iterate without scanf's and array is filled with <code>0</code>'s.</p>