title: Count and get integers from a string using C
body: <p>I am self teaching C programming. 
  I am trying to count number of int present in given string which are separated by space.</p>
  
  <p>exp:
  input str = "1 2 11 84384 0 212"
  output should be: 1, 2, 11, 84384, 0, 212 
  total int = 6</p>
  
  <p>When I try. It gives me all the digits as output which make sense since I am not using a right approach here.</p>
  
  <p>I know in python I can use str.split (" ") function which can do my job very quickly.</p>
  
  <p>But I want to try something similar in C. Trying to create my own split method.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  void count_get_ints(const char *data) {
      int buf[10000];
      int cnt = 0, j=0;
      for (int i=0; i&lt;strlen(data); i++) {
          if (isspace(data[i] == false)
              buf[j] = data[i]-'0';
              j++;
      }
      printf("%d", j);
  
  }
  
  // when I check the buffer it includes all the digits of the numbers.
  // i.e for my example.
  // buf = {1,2,1,1,8,4,3,8,4,0,2,1,2} 
  // I want buf to be following 
  // buf = {1,2,11,84384,0,212}
  </code></pre>
  
  <p>I know this is not a right approach to solve this problem. One way to keep track of prev and dynamically create a memory using number of non space digits encountered. 
  But I am not sure if that approach helps.</p>