title: How to make a copy of a linked list in C?
body: <p>This is my function to copy a list. The error is that it always copies the first element twice. What am I doing wrong? </p>
  
  <pre><code>Node *copy(Node *list) {
  
    Node *newlist, *p;
  
    p = malloc(sizeof(Node));
    newlist = p;
  
    while (list != NULL) {
        strcpy(p-&gt;airport, list-&gt;airport);
        p = p-&gt;next;
        p = malloc(sizeof(Node));
        list = list-&gt;next;
    }
  
    return newlist;
  }
  </code></pre>