I have a situation where I need to store a series of objects (they're actually 3d objects, so each structure will have an array of points/faces plus position/rotation info inside)
however I don't know how many objects there are, so I need to use malloc, And I'm getting really confused over what the syntax should be (or if I have the method totally wrong)
struct object
{
int *q;
};
//this curently is just a placeholder while I get the rest of it working, the pointer q just points to an array of floats.
struct object *p;
p=malloc(16*sizeof(struct object));
that is how I would expect to allocate an array of 16 structs to pointer p, however when I try to access it as an array, I get stuck
I think it should be something like
p[n]->q=malloc (16*sizeof(float));
to allocate an array of 16 floats to the pointer q in the nth structure of the array pointed to by p.
this just gives invalid argument of type "->" error. though I can't find any info on what I'm doing wrong (this is about then tenth attempt to get something working, there's probably something silly I'm missing, but I'm still a beginner so go easy on me.....
thanks
-mark