title: How to copy char *str to char c[] in C?
body: <p>Trying to copy a <code>char *str</code> to <code>char c[]</code> but getting segmentation fault or invalid initializer error.</p>
  
  <p>Why  is this code is giving me a <strong>seg fault</strong>?</p>
  
  <pre><code>char *token = "some random string";
  char c[80];  
  strcpy( c, token);
  strncpy(c, token, sizeof c - 1); 
  c[79] = '\0';
  char *broken = strtok(c, "#");
  </code></pre>