title: Attempting to parse numbers from strings and store in array but array seems to have no contents after more than one iteration
body: <p>My program has the goal of parsing the string &quot;Ge34eks-f10or-Gee59ks&quot;. It does this by using strtok to split on delimiter '-' into three tokens Ge34eks, f10or, and Gee59ks. Each token is passed into num_extraction func with the goal of getting the numbers from each token: 34, 10, 59. I want to keep spaces between each token's numbers, so they will be stored in an array with a zero in between each number : [34, 0, 10, 0, 59]. When attempting to print array nothing appears. Note: The while loop handles the second and third token, so if it is commented out, the first token number,34,is correctly printed.</p>
  <p>Specific issue: Nothing is printed? And no error is given
  Guesses: Either something wrong with my count variable or my array is not properly storing the numbers.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ctype.h&gt;
  
  
  int* num_extraction(char* a, int* arr, int* index) 
  {
      char* p = a;
      //int i = 0;
      while (*p)
      {  // While there are more characters to process...
          if (isdigit(*p) || ((*p == '-' || *p == '+') &amp;&amp; isdigit(*(p + 1))))
          {
              // Found a number
              arr[*index] = strtol(p, &amp;p, 10);  // Read number
              //printf(&quot;%d\n&quot;, val);          // and print it.
              *(index)++;
          }
          else
          {
              // Otherwise, move on to the next character.
              p++;
          }
  
      }
      return arr;
  
  }
  
  int main()
  {
      char str[] = &quot;Ge34eks-f10or-Gee59ks&quot;;
      int array[100] = { 0 };
      //int* p = array;
      int count = 0;
      int* q = &amp;count;
   
   
      // Returns first token
      char *token = strtok(str, &quot;-&quot;);
      num_extraction(token, array, q);
      count += 2;
     
      // Keep printing tokens while one of the
      // delimiters present in str[].
      
      while (token != NULL) // problem starts here if loop is commented out first token number is printed
      {
          //printf(&quot;%s\n&quot;, token);
          token = strtok(NULL, &quot;-&quot;);
          num_extraction(token, array, q);
          count += 2;
      }
      
      for(int i = 0; i &lt; count; i++)
      {
          printf(&quot;%d\n&quot;, array[i]);
      }
      //printf(&quot;%d\n&quot;, count);
      return 0;
  }
  </code></pre>
  <p>Verion 2</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ctype.h&gt;
  
  char* char_extraction(char* a, char* arr, int* index) 
  {
      char* p = a;
      
      for( int i = 0; i &lt; strlen(p); i++)
      {
          printf(&quot;%s\n&quot;, &quot;test&quot;); // ISSUE: ONLY PRINTS TWICE?
          if(isalpha(p[i]))
          {
              
              arr[*index] = p[i];
              //printf(&quot;%c\n&quot;, arr[*index]);  
              *(index)++;
          }
      }    
      return arr;
  
  }
  
  
  int main()
  {
      char str[] = &quot;Ge34eks-f10or-Gee59ks&quot;;
      int array[100] = { 0 };
      char array1[100] = &quot;&quot;;
      int count1 = 0;
      int* r = &amp;count1;
   
   
      // Returns first token
      char *token = strtok(str, &quot;-&quot;);
      
      char_extraction(token, array1, r); // called once 
    
      count1 += 2;
     
      // Keep printing tokens while one of the
      // delimiters present in str[].
      
      
    
      while ((token = strtok(NULL, &quot;-&quot;)) != NULL) 
      {
          
          char_extraction(token, array1, r); // should be called twice
          count1 += 2;
      }
      
      
      for(int i = 0; i &lt; count1; i++)
      {
          printf(&quot;%c\n&quot;, array1[i]);
      }
      
      //printf(&quot;%d\n&quot;, count);
      return 0;
  }
  
  
  </code></pre>