title: Create Dynamically Allocated Array with Pointers to Structs C++
body: <p>So I currently have a simple struct (linkedlist) that I will be using in a HashMap:</p>
  
  <pre><code>struct Node {
      std::string key, value;
      Node* head;
  }
  </code></pre>
  
  <p>I'm currently trying to dynamically allocate an array with pointers to each struct. This is what I have right now ...</p>
  
  <pre><code>Node* nodes = new Node[100]
  </code></pre>
  
  <p>I understand this allocates an array of 100 nodes into memory (which I will have to delete later on); however, upon iteration to try to transverse these nodes (which I an implementing as a linked list)...</p>
  
  <pre><code>for (int x = 0; x &lt; 100; x++) {
      Node current = nodes[x]; // Problem is I wanted an array to node pointers. This is not a pointer.
      while (current != nullptr) { // this isn't even legal since current is not a pointer.
          // DO STUFF HERE
          current = current.next; // This is not a pointer access to a method. I'm looking to access next with current-&gt;next;
      }
  }
  </code></pre>
  
  <p>Hopefully I was clear enough. Can someone how to allocate a dynamic array of pointers to structs? So far I'm able to dynamically allocate an array of structs, just not an array of pointers to structs.</p>