title: How do you move between nodes of a linked list?
body: <p>This is a piece of code that tries to build a linked list.</p>
  
  <pre><code>struct node {
      char name[20];
      int age;
      int height;
      node* next; // Pointer to the next node
  };
  node* startPTR = NULL;
  
  void addNode_AT_END() {
      node *temp1;
      node *temp2;
  
      temp1 = new node;  
  
      cout &lt;&lt; "Enter the name : ";
      cin  &gt;&gt; temp1-&gt;name;
      cout &lt;&lt; endl &lt;&lt; "Enter the age : ";
      cin  &gt;&gt; temp1-&gt;age;
      cout &lt;&lt; endl &lt;&lt; "Enter height : ";
      cin  &gt;&gt; temp1-&gt;height;
  
      temp1-&gt;next = NULL;
  
      if( startPTR == NULL) {
         startPTR = temp1; 
      }  else {
         temp2 = startPTR;
  
         while( temp2-&gt;next != NULL )
             temp2 = temp2-&gt;next;
  
         temp2-&gt;next = temp1;
      }
   }
  </code></pre>
  
  <p>The following is diagram after 2 back to back calls to the above function.</p>
  
  <pre><code>start = addr1;
  |
  V
  (addr1) ----&gt; (addr2) ----&gt; (NULL)      at end
  ^
  |
  temp2
  </code></pre>
  
  <p>where addr1 and addr2 are the address of the first and second nodes respectively.</p>
  
  <p><strong>What happens after the third call ? How the iteration will go on for the third call?</strong> I am unable to understand how the <code>list</code> links up after the second call.According to me all that has been build up till know will vanish.Then how will list move further ? How is node placed during the third call?</p>