-2

I have following struct

typedef struct {
    double x;
    double y;
} Point;

I want to create an array of it with defined size and clear it use this code:

Point *temppoints = new Point[pointCounts];
delete []temppoints;

However Xcode won't compile because of the new and delete.

Any advise?

too honest for this site
  • 11,797
  • 4
  • 29
  • 49
Rendy
  • 5,421
  • 12
  • 48
  • 92

1 Answers1

2

The new and delete keywords are C++ only. If you're using C, you need to use the malloc and free functions:

Point *temppoints = malloc(pointCounts * sizeof(Point));
...
free(temppoints);
dbush
  • 186,650
  • 20
  • 189
  • 240