title: Iteration through a linked list against itself not working as expected
body: <p>I am very sorry if this has been answered before.</p>
  <p>Upon running this code I wish to iterate through a linked list and then iterate through it again for each element in the list. I would love to know what on earth I am doing wrong here. Thanks.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  
  typedef struct node {
      int data;
      struct node *next;
  } node_t;
  
  node_t * push_end(node_t * end, int data) {
      end-&gt;next = (node_t *) malloc(sizeof(node_t));
      end-&gt;next-&gt;data = data;
      end-&gt;next-&gt;next = NULL;
      return end-&gt;next;
  }
  
  int main() {
  
      node_t * head = (node_t *) malloc(sizeof(node_t));
      head-&gt;data = 0;
      head-&gt;next = NULL;
  
      node_t * end = head;
  
      end = push_end(end, 1);
      end = push_end(end, 2);
  
      node_t *i_obj = head;
      node_t *j_obj = head;
  
      while(i_obj != NULL) {
          while(j_obj != NULL) {
              printf(&quot;%d, %d | &quot;, i_obj-&gt;data, j_obj-&gt;data);
              j_obj = j_obj-&gt;next;
          }
          i_obj = i_obj-&gt;next;
      }
  }
  </code></pre>
  <p>Expected output:
  <code>0, 0 | 0, 1 | 0, 2 | 1, 0 | 1, 1 | 1, 2 | 2, 0 | 2, 1 | 2, 2 |</code></p>
  <p>Actual output:
  <code>0, 0 | 0, 1 | 0, 2 |</code></p>