title: How to store data from pointer returned by strtok into struct without it being lost?
body: <p>I have a malloced string that I needed to parse. I did all of the parsing using <code>strtok()</code>. <code>Strtok</code> has returned a pointer to me and if I <code>printf</code> using that pointer the correct part of the parsed string gets printed. Afterwards I will be freeing the malloced string that the pointer returned by <code>strtok</code> was pointing too. </p>
  
  <p>How do I store what the pointer was pointing at into a struct such that the value remains in the struct variable even after the main string has been freed.</p>
  
  <p>String: <code>Tommy-1234567</code></p>
  
  <p>My <code>strtok</code> return pointer:</p>
  
  <pre><code>char *studentName= strtok(String1,"-");
  char *studentNo= strtok(NULL,"-");
  </code></pre>
  
  <p>My struct:</p>
  
  <pre><code>typedef struct Student{
      char *name;  //Want name to be stored here even after string is freed
      int  *studentNumber;  //Want no. to be stored here even after string is freed
  }Student;
  </code></pre>