title: How does the strtok function in C work?
body: <p>I found this sample program which explains the <code>strtok</code> function:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main ()
  {
      char str[] ="- This, a sample string.";
      char * pch;
      printf ("Splitting string \"%s\" into tokens:\n",str);
      pch = strtok (str," ,.-");
      while (pch != NULL)
      {
          printf ("%s\n",pch);
          pch = strtok (NULL, " ,.-");
      }
      return 0;
  }
  </code></pre>
  
  <p>However, I don't see how this is possible to work. </p>
  
  <p>How is it possible that <code>pch = strtok (NULL, " ,.-");</code> returns a new token. I mean, we are calling <code>strtok</code>with <code>NULL</code> . This doesen't make a lot sense to me.</p>