title: How To Make Pointers that Point to Each Member of a List
body: <p>I have a list. Each element of the list is a struct.</p>
  
  <pre><code>struct A
  {
     int size;
  }
  </code></pre>
  
  <p>The data looks like:</p>
  
  <pre><code>list[0]-&gt;size = a number.
  </code></pre>
  
  <p>How can I assign a pointer to each member of the list?</p>
  
  <pre><code>int *p;
  for(i = 0; i &lt; listSize; i++)
  {
    p = &amp;list[i];
  } 
  </code></pre>
  
  <p>That won't work since I am assigning only one pointer to the last element of the list. Should I make a list of pointers?</p>
  
  <p>This should solve the XY problem.
  <strong>How do I create pointers for every element of my list?</strong></p>
  
  <p>EDIT:
  List looks like this</p>
  
  <pre><code>A **list;
  </code></pre>
  
  <p>I want to sort by pointers instead of by structures so that it is faster.</p>
  
  <p>Trying this now:</p>
  
  <pre><code>A ***p = (A***) malloc(sizeof(A***));
  
  for(i = 0; i &lt; listLength; i++)
      p[i] = &amp;list[i];
  
  for(i = 0; i &lt; listLength; i++)
      printf( p[i]-&gt;size); // Error.
  </code></pre>