I am trying to pass an array to a function but the value received is only the first value in the array. What am I doing wrong ? Here are the 3 functions that are involved in the operation.
void computeCScode (int temp1, int temp2, int code[])
{
if((temp1<100)&&(temp2<100))
{
code[0]=1;
code[1]=0;
code[2]=1;
code[3]=0;
}
else if((temp1<100)&&(temp2>=100&&temp2<=400))
{
code[0]=1;
code[1]=0;
code[2]=0;
code[3]=0;
}
...
}
void invert(int x1, int y1, int x2, int y2, int firstCode[], int secondCode[])
{
int ok=1;
int *temp;
temp=(int*)malloc(sizeof(firstCode));
int aux;
if(firstCode==0000) ok=1;
else ok=0;
...
}
void cs(HDC hdc, int x1, int y1, int x2, int y2)
{
int firstCode[4];
int secondCode[4];
FINISHED = FALSE;
DISPLAY=FALSE;
REJECTED=FALSE;
do
{
computeCScode(x1,y1,firstCode);
computeCScode(x2,y2,secondCode);
...
invert(x1,y1,x2,y2,firstCode,secondCode);
}while(!FINISHED);
}
After computeCScode, firstCode and secondCode are ok. But when passing them to invert, inside the function they only use the first value of the function. What did I forget?