0
我想将数组传递给函数,但接收到的值只是数组中的第一个值。我究竟做错了什么 ?这是操作中涉及的3个功能。将数组传递到函数错误
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);
}
computeCScode,firstCode和secondCode后都OK。但是当它们通过反转时,它们只能使用函数的第一个值。我忘了什么?
请减少您的示例,使其仅包含查看问题所需的代码。你输入的代码太长了。 (通过这样做,你也可以自己找到错误的原因。) – krlmlr