title: How to Create an array of pointers to structs?
body: <p>I have</p>
  
  <pre><code>struct Item {int id; string name; float sellprice; int qstock;};
  struct Sale {int id; int quantity; double tcost;};
  </code></pre>
  
  <p>I want to create an array, with 100 indexes, such that when i dereference the array position, 
  i'll be at the struct position. Also the structs must be assigned memory using malloc.</p>
  
  <p>e.g.</p>
  
  <pre><code>*(items[0]).id=10; //will store id=10 in first index struct.
  </code></pre>
  
  <p>however i am unsure how to declare the array of pointers.
  do i need to make a pointer to the struct, and then an array of that pointers?</p>
  
  <pre><code>itemsPtr *Item;
  itemsPtr items[100];
  items[0]-&gt;id=10; 
  </code></pre>
  
  <p>or will it be something like.</p>
  
  <pre><code>Item *items[100];
  </code></pre>
  
  <p>I tried a few of these variants and have had problems. Also when i have to pass this array of pointers to a function do i just pass the array name as that is a pointer or what?</p>