title: List altered without order to do so
body: <p>I don't even know how to title this question, but it's following: in my code I'm duplicating a Queue (which in this case is nearly the same as a linked list ) and changing the duplicate, but the original is getting changed aswell. I don't see where I'm changing it so, i hope someone can help. the printf are to ilutrate my point, they should have the same output all the way.</p>
  
  <pre><code>int list(Queue list, int sort )
  {
      Queue temp = list ;
  
      int s=temp-&gt;size ;
      int i=0, j, p;
      int *sender, *receiver ;
      char **sorted ;
      char* t ;
  
      if ( list == NULL )
      {
          puts("NULL") ;
          return 0;
      }
  
  
      t=(list-&gt;head-&gt;item-&gt;text);
      printf("%s", t );
  
      sorted = malloc((s + 1) * sizeof(char *));
      sender = malloc( s * sizeof(int));
      receiver = malloc( s * sizeof(int));
  
      while ( i &lt; s )
      {
          /* It's changing somewhere around here */
  
          sorted[i] = malloc(strlen(temp-&gt;head-&gt;item-&gt;text) + 1);
          strncpy( sorted[i] , temp-&gt;head-&gt;item-&gt;text, strlen(temp-&gt;head-&gt;item-&gt;text) + 1 ) ;
          sender[i] = temp-&gt;head-&gt;item-&gt;sender ;
          receiver[i] = temp-&gt;head-&gt;item-&gt;receiver ;
          if (temp-&gt;head-&gt;next == NULL)
          break;
          temp-&gt;head = temp-&gt;head-&gt;next ;
          i++ ;
      }
  
      t=(list-&gt;head-&gt;item-&gt;text);
      printf("%s", t );
  </code></pre>