title: How to get the string value from a char array in C
body: <p>I have a <code>char array</code> in <code>C</code></p>
  
  <pre><code>#define BUFSIZE 2048
  unsigned char buf[BUFSIZE];
  
  char request[10];
  strcat(request "GET key01");
  request[10] = '\0';
  
  buf = request;
  </code></pre>
  
  <p>The request is coming from a the network with a <code>client-server socket</code> simulation, but I did not include that here to keep it simple.</p>
  
  <p>Anyways, I have to tokenize the <code>buf</code> string, but also keep an untokenized copy. I tried this:</p>
  
  <pre><code>char* buf_for_token = buf;
  printf("What is the buf before tokenization? %s\n", buf);
  
  const char s[2] = " ";
  char *token;
  token = strtok(buf_for_token, s);
  token = strtok(NULL, s);
  
  printf("What is the buf after tokenization? %s\n", buf);
  </code></pre>
  
  <p>My output is:</p>
  
  <pre><code>What is the buf before tokenization? GET key01
  What is the buf after tokenization? GET
  </code></pre>
  
  <p>I would instead like:</p>
  
  <pre><code>What is the buf before tokenization? GET key01
  What is the buf after tokenization? GET key01
  </code></pre>
  
  <p>How can I get the value of a string from a char array and save a copy that I can manipulate without affecting the original value?</p>