title: strtok problem in visual c++
body: <p>I am trying the strtok in visual c++, but it seems not working. This not my first time using strtok, but i just counldnt figure out what is wrong with it. the code is quite simple.</p>
  
  <p>in main</p>
  
  <pre><code> cout&lt;&lt;getLevels("/'Group'/'Channel1'")&lt;&lt;endl;
  </code></pre>
  
  <p>in getLevels()</p>
  
  <pre><code>int getLevels(char * fullPath){
   int level=0;
   char *nextToken;
   char * pch=strtok_s(fullPath, "/", &amp;nextToken);// broken at here
   while(pch!=NULL){
    level++;
    cout&lt;&lt;level&lt;&lt;":"&lt;&lt;pch&lt;&lt;endl;
    pch=strtok_s(NULL, "/",&amp;nextToken);
   }
   return level;
  
  }
  </code></pre>
  
  <p>it breaks at line</p>
  
  <pre><code> char * pch=strtok_s(fullPath, "/", &amp;nextToken);
  </code></pre>
  
  <p>with error: </p>
  
  <pre><code>Unhandled exception at 0x10273de8 (msvcr100d.dll) in tdmsTest.exe: 0xC0000005: Access violation writing location 0x0041c840.
  </code></pre>
  
  <p>and the cursor is pointing to this line in strtok_s.ini</p>
  
  <pre><code> for ( ; *str != 0 ; str++ )
      {
          if (map[*str &gt;&gt; 3] &amp; (1 &lt;&lt; (*str &amp; 7)))
          {
              *str++ = 0; // pointing here
              break;
          }
      }
  </code></pre>
  
  <p>i tried it in strtok() instead of strtok_s() before, but it has the same problem.
  can any one tell me what is wrong with my code?</p>