title: strtok() issue: If tokens are delimited by delimiters,why is last token between a delimiter and the null '\0'?
body: <p>In the following program, <code>strtok()</code> works as expected in the major part but I just can't comprehend the reason behind one finding.  I have read about <code>strtok()</code> that:</p>
  <blockquote>
  <blockquote>
  <p>To determine the beginning and the end of a token, the function first scans from the starting location for the first character not contained in delimiters (which becomes the beginning of the token). And then scans starting from this beginning of the token <strong>for the first character contained in delimiters, which becomes the end of the token.</strong></p>
  </blockquote>
  <p>Source: <a href="http://www.cplusplus.com/reference/cstring/strtok/" rel="noreferrer">http://www.cplusplus.com/reference/cstring/strtok/</a></p>
  </blockquote>
  <p>And as we know, <code>strtok()</code> places a <code>\0</code> at the end of each token. But in the following program, the last delimiter is a dot(<code>.</code>), after which there is <strong>Toad</strong> between that dot and the quotation mark (<code>&quot;</code>). Now the dot is a delimiter in my program, but there is no delimiter after <strong>Toad</strong>, not even a white space (which is a delimiter in my program). Please clear the following confusion arising from this premise:</p>
  <p>Why is <code>strtok()</code> considering <strong>Toad</strong> as a token even though it is not between 2 delimiters? This is what I read about <code>strtok()</code> when it encounters a NULL character (<code>\0</code>):</p>
  <blockquote>
  <blockquote>
  <p>Once the terminating null character of str has been found in a call to strtok, all subsequent calls to this function with a null pointer as the first argument return a null pointer.</p>
  </blockquote>
  <p>Source: <a href="http://www.cplusplus.com/reference/cstring/strtok/" rel="noreferrer">http://www.cplusplus.com/reference/cstring/strtok/</a></p>
  </blockquote>
  <p>Nowhere does it say that once a null character is encountered,a pointer to the beginning of the token is returned (we don't even have a token here as we didn't get an end of the token as there was no delimiter character found after the scan begun from the beginning of the token (i.e. from 'T' of Toad), we only found a null character, <strong>not a delimiter</strong>). So why is the <strong>part between last delimiter and quotation mark of argument string</strong> considered a token by <code>strtok()</code>? Please explain this.</p>
  <h3>Code:</h3>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main ()
  {
    char str[] =&quot; Falcon,eagle-hawk..;buzzard,gull..pigeon sparrow,hen;owl.Toad&quot;;
    char * pch=strtok(str,&quot; ;,.-&quot;);
  
      while (pch != NULL)
    {
      printf (&quot;%s\n&quot;,pch);
      pch = strtok (NULL, &quot; ;,.-&quot;);
    }
  
    return 0;
  }
  </code></pre>
  <h3>Output:</h3>
  <blockquote>
  <p>Falcon<br />
  eagle<br />
  hawk<br />
  buzzard<br />
  gull<br />
  pigeon<br />
  sparrow<br />
  hen<br />
  owl<br />
  Toad</p>
  </blockquote>