title: How to create an array of pointers to structs? C++
body: <p>I wrote this piece of code that I am not sure exactly how it works, but it works. This is the code:</p>
  
  <pre><code>  struct node
  {
      string data;
      node *chain;
  };
  
     int tablesize=10;
  
    node *ptr [tablesize];
  
    for (i=0; i&lt;tablesize; i++)
  {
      ptr[i]=new node;
      ptr[i]-&gt;data="Empty";
      ptr[i]-&gt;chain=NULL;
  }
  </code></pre>
  
  <p>If I understand it correctly, first I create an array of 10 pointers, then I assign each pointer with a new node? Why does it work only when I dereference it twice though? 
  (                      ptr[i]->data="Empty";)</p>