title: Linked List, insert at the end C++
body: <p>I was writing a simple function to insert at the end of a linked list on C++, but finally it only shows the first data. I can't figure what's wrong. This is the function:</p>
  
  <pre><code>void InsertAtEnd (node* &amp;firstNode, string name){
  
          node* temp=firstNode;
  
          while(temp!=NULL) temp=temp-&gt;next;
  
              temp = new node;
          temp-&gt;data=name;
          temp-&gt;next=NULL;
  
          if(firstNode==NULL) firstNode=temp;
  
  }
  </code></pre>