title: Reversing tokens from strtok results in empty string
body: <p>I am attempting to reverse the words/tokens returned from strtok, I am iterating over each token in reverse order and assigning each ith value to a buffer called <code>new</code>. I can print each ith value/char of the token pointer <code>p</code> but for some reason I am having trouble assigning the chars <code>p</code> is pointing to the buffer <code>new</code>. What am I missing or doing wrong here?</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  int main(void) {
      char str[] = &quot;This is an example!&quot;;
      char *new = malloc(strlen(str));
      char *p = strtok(str, &quot; &quot;);
      size_t j = 0;
      while (1) {
          for (size_t i=strlen(p)-1; i&gt;-1; i--) {
              new[j++] = p[i];
          }
          p = strtok(NULL, &quot; &quot;);
          if (!p)
              break;
          new[j++] = ' ';
      }
      printf(&quot;%s\n&quot;, new);
      return 0;
  }
  </code></pre>
  <p>stdout:</p>
  <pre><code>
  </code></pre>
  <p>Intended/expected output:</p>
  <pre><code>sihT si na !elpmaxe
  </code></pre>