Original Post
I had to write a program where the user enters the cordinates of the vertices of an n-sided polygon. Here value of "n" is not known until runtime. So I created a pointer to CPoint say P.
CPoint* P;
The user enters the co-ordinates thru a dialog box which contains two edit boxes for x and y co-ordinates and two buttons - Add & Ok.
When the user enters a co-ordinate and presses Add, the co-ordinate gets added to the array P. When the user presses Ok the program draws the polygon with the points in the array P as vertices.
The problem is that each time the user presses Add button I want to dynamically allocate memory for the new Point with the help of the following statement
P[count] = new CPoint(x,y);
count++;
where count is the number of points entered in the array and x & y are the co-rdinates.
But this doesnt seem to be working and the program crashes.
Please help me...
Thanx a lot.
"A byte is a large bit to crunch!"