In my h file I declare a var that later should be an array:
@interface myClass : CCNode {
CGPoint *mVertices;
}
@end
In my init method:
mVertices = malloc(size * size * sizeof(CGPoint));
mVertices[0][0] = ccp(0,0);
At this last line I get an error Subscripted value is neither array nor pointer.
Why do I get this error and how to solve that problem?
Your array is not two dimensional. It’s just a list of vertices.
If you want to allocate space for a dynamic two dimensional array in C you could do:
I used
callocinstead ofmallocto get CGPoints initialized with 0.0.