title: How to append to the end of a C Array
body: <p>I've been programming for a while in objective-c, but I've unfortunately never delved very deeply into C and memory pointers, although I do have a rudimentary understanding of them. I'm working with an array of CLLocationCoordinate2D structures, and I'm trying to figure out how to append to the array. First of all, I get the </p>
  
  <pre><code>NSString *aString; //a bunch of coordinates
  CLLocationCoordinate2d *coordinates;
  int length;
  
  doSomethingCool(aString, &amp;coordinates, &amp;length);
  </code></pre>
  
  <p>after I do something cool, I want to preserve it in a class variable. If I simply do something like</p>
  
  <pre><code>points = newPoints
  </code></pre>
  
  <p><em>points</em> contains the appropriate contents. However, if I try to do something like this:</p>
  
  <pre><code>points = malloc(sizeof(CLLocationCoordinate2D) * length);
  points[0] = *newPoints;
  </code></pre>
  
  <p><em>points</em> ends up with contents different from <em>newPoints</em>.</p>
  
  <p>Ultimately my goal is to be able to append to <em>points</em> based on <em>length</em>, but I'm not going to be able to do that if I can't get the above code to work. What am I doing wrong?</p>