-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
  • 12,050
  • 4
  • 30
  • 52
Rendy
  • 5,572
  • 15
  • 52
  • 95

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
  • 205,898
  • 23
  • 218
  • 273