title: Filter linked list and return new linked list C
body: <p>I am trying to filter a linked list. Since I don't want to change the original linked list, I want to create a sub linked list and return it instead. </p>
  
  <p>I am having troubles with this because I only know how to get 1 node from the filtering process, but I don't know how to move around and add nodes from the original linked list to the sub linked list.</p>
  
  <p>I have a struct like this (This represents an entry in a hash table):</p>
  
  <pre><code>typedef struct Entry {
     char *word;
     int len;
     struct Entry *next;
  } Entry;
  </code></pre>
  
  <p>My filter function will receive the word length and the original linked list as arguments, then find nodes that have the same value of len. Whenever it finds a node that has the same value of len, it adds the node to another linked list. Finally it returns the new linked list.</p>
  
  <pre><code>struct Entry* filterLen(int len, struct Entry *en) {
     struct Entry *temp = (struct Entry *)malloc(sizeof(struct Entry));
  
     while(en-&gt;next != NULL) {
        if (en-&gt;len == len) {
           // assign values to temp list
           temp-&gt;word = en-&gt;word;
           temp-&gt;len = en-&gt;len;
           temp-&gt;next = en;
        }
  
        en = en-&gt;next; // move through list
     }
  
     return temp;
  }
  </code></pre>