Checking String with is_numeric in C I am a newbie in stack exchange code review. I just wrote a C function where the function checks if the given string is numeric or not. What do you think about my way of doing this? And could this be done in other ways?
#include &lt;stdio.h&gt;
#include &lt;stdbool.h&gt;

bool is_numeric(const char* str)
{
    while (isspace(*str))
       str++;
    
    if (*str == '-' || *str == '+')
       str++;

    while (*str)
    {
        if (!isdigit(*str) &amp;&amp; !isspace(*str))
            return false;
        str++;
    }

    return true;
}

int main(int argc, char** argv)
{
  printf(&quot;%s\n&quot;, is_numeric(&quot;123436&quot;)  ? &quot;true&quot; : &quot;false&quot;); // should be true
  printf(&quot;%s\n&quot;, is_numeric(&quot;123.436&quot;) ? &quot;true&quot; : &quot;false&quot;); // should be false
  printf(&quot;%s\n&quot;, is_numeric(&quot;    567&quot;) ? &quot;true&quot; : &quot;false&quot;); // should be true
  printf(&quot;%s\n&quot;, is_numeric(&quot;235   &quot;)  ? &quot;true&quot; : &quot;false&quot;); // should be true
  printf(&quot;%s\n&quot;, is_numeric(&quot;794,347&quot;) ? &quot;true&quot; : &quot;false&quot;); // should be false
  printf(&quot;%s\n&quot;, is_numeric(&quot;hello&quot;)   ? &quot;true&quot; : &quot;false&quot;); // should be false
  printf(&quot;%s\n&quot;, is_numeric(&quot;-3423&quot;)   ? &quot;true&quot; : &quot;false&quot;); // should be true
}

Thanks in advance!
regarding:
if (!isdigit(*str) &amp;&amp; !isspace(*str))

the isdigit() handles 0...9, so catches if any of the passed in char array is not numeric.
The &amp;&amp; !isspace(*str))  has nothing to do with numeric values