   Need help with error
int width=800,height=600,objects=0,maxobjects=OBJECT_CLUSTER;float theta=0.0,ratio=0.75,elapsed_time,last_time,t;typedef struct{  float x,y,z;}VERTEX;typedef struct{  int v, max_v;  float x,y,z;  VERTEX *vertex;}OBJECT;OBJECT *object;void Init3D(void){  object=(OBJECT*)malloc(OBJECT_CLUSTER*sizeof(OBJECT));}void createObject(float new_x,float new_y,float new_z){  ++objects;  if(objects>maxobjects)  {    maxobjects+=OBJECT_CLUSTER;    object=realloc(object,maxobjects*sizeof(OBJECT));  }  object[objects-1].v=0;  object[objects-1].max_v=VERTEX_CLUSTER;  object[objects-1].x=new_x;  object[objects-1].y=new_y;  object[objects-1].z=new_z;  object[objects-1].vertex=(VERTEX*)malloc(VERTEX_CLUSTER*sizeof(VERTEX));}void createVertex(OBJECT *obj,float new_x,float new_y,float new_z){  ++obj->v;  if(obj->v>obj->max_v)  {    obj->max_v+=VERTEX_CLUSTER;    obj->vertex=realloc(obj->vertex,obj->max_v*sizeof(OBJECT));  }  obj->vertex[obj->v-1].x=new_x;  obj->vertex[obj->v-1].y=new_y;  obj->vertex[obj->v-1].z=new_z;}int main(){  Init3D();  createObject(1,2,3);  createVertex(object[0],3,3,3);}...I get an error "incompatible type for argument 1 of 'createVertex'" What type am i supposed to use then? :/   
  I think that by indexing the object array, you are, in essence, dereferencing it.  You might try passing just object, or passing &object[0], which I think is clearer.   ;  tnx =D i added the & to object[0] that fixed it.   ;  You need to send a pointer to an OBJECT   It appears as you are sending an Actual object.  If you wish to operate on the ith object in your array you'd do:createVertex(&object,3,3,3);or maybe:createVertex((object + i),3,3,3);Where i is the object you wish to operate on(0 in the case of the last line)I think that's correct, hope that helps.EDIT: grr, too slow   ;void createVertex(OBJECT obj,float new_x,float new_y,float new_z){  ++obj.v;  if(obj.v>obj.max_v)  {    obj.max_v+=VERTEX_CLUSTER;    obj.vertex=realloc(obj.vertex,obj.max_v*sizeof(OBJECT));  }  obj.vertex[obj.v-1].x=new_x;  obj.vertex[obj.v-1].y=new_y;  obj.vertex[obj.v-1].z=new_z;}...  createVertex(object[0],3,3,3);...Is there anything logically wrong with this? Looks like it works but i dont want a risk of crashing/etc.Edit: i've tried using it and it doesnt work. The program cant read the numbers from the dynamic array correctly if i tried the above so i went back to the last one with *, ->, & stuff.[Edited by - biscuitz on June 16, 2006 2:45:18 PM];  I can't see anything immediately wrong with it, but I'm at work, so I'll have to look more later.  I do find it a little worrisome that you're using C.  Is there a reason you don't want to use C++?  I abso-tively love std::vector and std::list and such for handling situations like these.   ;  It's ok syntactically, but the semantics are not right: C and C++ are pass-by-value (unless you explicitly request otherwise), so you pass a *copy* of the OBJECT from the array, modify the copy, and then at the end of the function the copy is thrown away (because it's a local variable and hasn't been assigned anywhere) and the global array is untouched.The other posters have it correct in terms of how to set up a pointer. However, if you used C++, you could pass by reference instead: have the function accept "OBJECT&" rather than "OBJECT", and everything else stays the same. Basically this generates pointer-like stuff for you "under the hood", but is safer and cleaner (and you really shouldn't think of it in terms of the implementation details: see here for a full rundown on references).   ;  what do you mean by "Correctly". if your getting messed up number , the problemmight be with the float vars. floats have a little strange behavoir ,for example if you write 1/3 the result is 0 . if that seems to be the problem , i advice that you google it.;  Zahlman i dont understand what you're saying :/Code Fusion I tried to access the data and it kept giving me 0 no matter what i set the numbers to (as far as i could figure). Oh wait... i remember, it wouldn't read the y/z values I think, because i found it would read one of the values but not the others.I tried to learn C++ templates but i got lost. And I already new more about C memory functions than the c++ templates so i decided to keep going C rather than trying to switch to something new when i'm so close to finishing the code.   