title: Copy the linked list pointed by a parameter
body: <p>I'm trying to implement a function which will make a copy of the list pointed by parameter. I store head pointers to nodes in some array and the parameter is just its index. This is my attempt:</p>
  
  <pre><code>void copy(node **array, int *amount_of_lists, int parameter)
  {
      node *current = array[parameter];
      array[(*amount_of_lists) - 1] = malloc(sizeof(node));
      node *new_list = array[(*amount_of_lists) - 1];
  
          while(current-&gt;next != NULL)
          {
              new_list-&gt;next = malloc(sizeof(node));
              new_list-&gt;str = current-&gt;str;
              current = current-&gt;next;
              new_list = new_list-&gt;next;
          }
  }
  </code></pre>
  
  <p>Before I call copy function I allocate memory for new the head pointer in mentioned array (last index (amount of lists - 1)). Unfortunately, something is wrong in this function; does anyone know what should it look like?</p>