c++ dynamic array of structures
<p>Could you help me organize a dynamic array of points?</p>

<p>I have coped with a dynamic array of integers. But I don't know
how to organize it with structures.</p>

<p>Here is my code so far...</p>

<pre><code>#include "stdafx.h"
#include &lt;cstdlib&gt;;
#include &lt;iostream&gt;;
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
  int i = 0; // Array index.
  struct Point
  {
    int x;
    int y;
  };
  size_t n = sizeof(int);
  int * points = static_cast&lt;int*&gt;(malloc(n));
  char command;
  do
  {
    cout &lt;&lt; "n - Create new point." &lt;&lt; endl;
    cout &lt;&lt; "q - Quit." &lt;&lt; endl;
    cout &lt;&lt; "Input a new command: ";
    cin &gt;&gt; command;
    if (command == 'n')
    {
      points[i] = 1;
      i++;
      /* points[i] = new Point();
         points[i].x = 1;
         points[i].y = 1; */
      // cout&lt;&lt;"("&lt;&lt;point1.x&lt;&lt;","&lt;&lt;point1.y&lt;&lt;")";               
    }               
    else if (command == 'q')
    {       
      for (int j = 0; j &lt; i; j++)
        cout &lt;&lt; points[j] &lt;&lt;endl;
      system("pause");
      return 0;
    }
    else
    {
      cout &lt;&lt; "Please, enter a correct command." &lt;&lt; endl &lt;&lt; endl &lt;&lt; endl;               
    }
  } while (true);
  system("pause");  
  return 0;
}
</code></pre>
