title: C strtok() split string into tokens but keep old data unaltered
body: <p>I have the following code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main (void) {
      char str[] = "John|Doe|Melbourne|6270|AU";
  
      char fname[32], lname[32], city[32], zip[32], country[32];
      char *oldstr = str;
  
      strcpy(fname, strtok(str, "|"));
      strcpy(lname, strtok(NULL, "|"));
      strcpy(city, strtok(NULL, "|"));
      strcpy(zip, strtok(NULL, "|"));
      strcpy(country, strtok(NULL, "|"));
  
      printf("Firstname: %s\n", fname);
      printf("Lastname: %s\n", lname);
      printf("City: %s\n", city);
      printf("Zip: %s\n", zip);
      printf("Country: %s\n", country);
      printf("STR: %s\n", str);
      printf("OLDSTR: %s\n", oldstr);
  
      return 0;
  }
  </code></pre>
  
  <p>Execution output:</p>
  
  <pre><code>$ ./str
  Firstname: John
  Lastname: Doe
  City: Melbourne
  Zip: 6270
  Country: AU
  STR: John
  OLDSTR: John
  </code></pre>
  
  <p>Why can't I keep the old data nor in the <code>str</code> or <code>oldstr</code>, what am I doing wrong and how can I not alter the data or keep it?</p>