title: Testing input for numbers (else repeat) - C
body: <p>I have a problem. I have a working code but I need to redesign it.</p>
  
  <pre><code>    #include &lt;stdio.h&gt;
      #include &lt;stdlib.h&gt;
  
  int num_input(char *vyzva)
  {
      int input;
      while (scanf("%d", &amp;input) != 1) {
          fflush(stdin);
          printf("\nIt is not a number! Please repeat.\n\n");
          printf("%s", vyzva);
      }
      fflush(stdin);
      return input;
  }
  
  
  int main (void){
   int cislice;
  
  
   printf("Insert a number: ");
  
   cislice = num_input("Insert a number:");
  
   printf("Number is: %d", cislice);
  
  return 0;
  }
  </code></pre>
  
  <p>Main goal of the redesigned code is to check if the user ipnut is only number (same as working code).
  I need to get this input by fgets function a then convert string to number.</p>
  
  <p>For this test I can't use scanf. I was told that strtol function works for this, but I have no idea how. Can anyone show me, how to use strtol to check wether the input is number or some letters?</p>
  
  <p>It's a homework.</p>