title: Using a separate function to check if it's an integer input C Language
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;math.h&gt;
  
      void check(char *s){
          char str[24] = s;
          int i;
          fgets(str, sizeof(str), stdin);
          boolean valid = TRUE;
          for (i = 0; i &lt; strlen(str); ++i){
              if (!isdigit(str[i])){
              printf("NOT a valid Integer");
              valid = FALSE;
  
              break;
              }
          }
          printf("An integer!");
      }
  
      int main()
      {
          int userInput;
          char str;
  
          scanf("%d%c", &amp;userInput, &amp;str);
          check(str);
          .
          .
          .
  
  
          return 0;
      }
  </code></pre>
  
  <p>I keep getting error in my code, I'm trying to find a way to use a separate check function to check if the user input a valid integer, i.e.: numbers like 1,345, 7899,...are good; while typing 'a23','@3','12', '24.4',...will halt the program. Any ideas will help, thanks.
  C Language.</p>