title: Linked Lists Help C++
body: <p>I am having trouble in C++ putting and displaying array into a linked list. I'm having lots of trouble with linked lists in general</p>
  
  <p>Here is my code. It only displays the first number. (It should display 19 21 17 22 33)</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  struct node {
      int age;
      node *next;
  };
  
  void display(node *t)
  {
      node *temp = t;
      cout &lt;&lt; temp-&gt;age &lt;&lt; " ";
  }
  
  int main()
  {
      int Age[5] = { 19, 21, 17, 22, 33 };
  
      node* List = new node;
      List = NULL;
      node* temp2 = List;
  
      while (temp2 != NULL)
      {
          temp2 = temp2-&gt;next;
          node* List = new node;
          List = NULL;
          node* temp2 = List;
      }
  
      for (int i = 0; i &lt; 5; i++)
      {
          temp2 = new node;
          temp2 -&gt; age = Age[i];
          temp2 -&gt; next = NULL;
  
          if (List == NULL) 
              List = temp2;
      }
  
      display(List);
  
      system("PAUSE");
      return 0;
  }
  </code></pre>