title: Split C string after identifier
body: <p>Quick question: I want to split a string literal (a file path) at the last "/".</p>
  
  <p>So, from this: <code>"/folder/new/new2/new3"</code>
  to this as the result: <code>"/folder/new/new2"</code></p>
  
  <p>So basically, I always want the result to be one directory behind the absolute path provided.</p>
  
  <p>I've been using <code>strtok</code> something akin to this to get the last directory, but I don't know an easy way to get the <em>second to last</em> directory. :</p>
  
  <pre><code>    char *last
      char *tok = strtok(dirPath, "/");
      while (tok != NULL)
      {
           last=tok;
           tok = strtok(NULL, "/");
      }
  </code></pre>