hi
i want to create a global array of structs pointers to access later from a function but i am getting an error. i am not sure what i am doing wrong.
//////////////////////////
typedef struct {
int x;
int y;
int z;
int tilt;
int pan;
int roll;
} POS;
POS* cam0 = {
x = 61;
y = 8;
z = 20;
tilt = 0;
pan = 357;
roll = 0;
}
POS* cam1 = {
x = 261;
y = 23;
z = 0;
tilt = 110;
pan = 7;
roll = 22;
}
POS* cameras[2];
cameras[0] = cam0;
cameras[1] = cam1;
function loopPos()
{
for (i = 0; i < 2; i++) // repeat few times
{
cameras[i].x = 333; //ERROR COMES HERE
}
}
//////////////////////////////////
first i thought i should be able to do
POS* cameras[2] = { cam0, cam1 }
but it does not like it, then I am not sure why accessing the items in the array from the function is causing the crash. Actually doing the same ( cameras[0].x = 555; ) just after decalaring the array seems to work fine. Maybe it is a problem of scope? I thought that array should be global. I am calling the funcion from another file, but this one includes the one that defines the function, structs and the array...
thanks
enrike
Last edited by enrike; 12/09/09 09:00.