title: How to extract a negative number from a string
body: <p>I need help extracting numbers from a char.
  Lets say I have:</p>
  
  <pre><code>char str = "   ( 1   22  -4)";
  </code></pre>
  
  <p>I need to extract each integer and call another method.</p>
  
  <pre><code>while (*p) {
       if (isdigit(*p)) {
           int val = strtol(p, &amp;p, 10);
           on_int(val);
       } else {
           p++;
       }
   }  
  </code></pre>
  
  <p>I have extracted the integers successfully but I cannot figure out how to extract negatives.</p>
  
  <p>With this code I have extracted 1, 22, and 4. How do I get that negative infront of the 4?</p>