title: How do I split a string without strtok?
body: <p>I'm a beginner at C, please don't bash me.
  So, I have this function that gets the mask of an "ip/mask" type of string:</p>
  
  <pre><code>char *getmask(char n[]) {
      char x[255] = { 0 };
      strcpy(x, n);
      char *mask;
      mask = strtok(x, "/");
      mask = strtok(NULL, "/");
      return mask;
  }
  </code></pre>
  
  <p>The problem is that I need to do that on multiple "ip/mask" that are all in one string. So when I do this:</p>
  
  <pre><code>net = strtok(x4, " ");
  net = strtok(NULL, " ");
  while (net != NULL) {
      net = strtok(NULL, " ");
      strcpy(masca, "\n");
      strcpy(masca, getmask(net));
      //some other code
  }
  </code></pre>
  
  <p>The problem is that <code>strtok()</code> malfunctions since I call it at first in the while but then it gets called again in <code>getmask(net)</code>.</p>
  
  <p>Anyway to bypass it? And if not, how else can I split a string?</p>