title: strtok segmentation fault
body: <p>I am trying to understand why the following snippet of code is giving a segmentation fault:</p>
  
  <pre><code>void tokenize(char* line)
  {
     char* cmd = strtok(line," ");
  
     while (cmd != NULL)
     {
          printf ("%s\n",cmd);
          cmd = strtok(NULL, " ");
     } 
  }
  
  int main(void)
  {
     tokenize("this is a test");
  }
  </code></pre>
  
  <p>I know that strtok() does not actually tokenize on string literals, but in this case, <code>line</code> points directly to the string <code>"this is a test"</code> which is internally an array of <code>char</code>. Is there any of tokenizing <code>line</code> without copying it into an array?</p>