배열을 함수에 전달하려고했지만받은 값은 배열의 첫 번째 값만입니다. 내가 도대체 뭘 잘못하고있는 겁니까 ? 다음은 작동과 관련된 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;
...
} computeCScode, firstCode 및 secondCode 후
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);
}
확인합니다. 그러나 그들을 반전 시키려고 할 때, 함수 내에서 함수의 첫 번째 값만 사용합니다. 나는 무엇을 잊었 는가?
temp=firstCode;
firstCode=secondCode;
secondCode=temp;
당신이 정말로 다음 memcpy
을 사용하는 배열의 내용을 교환하려는 경우 또는 for
루프, 예를 들면 :
문제를 확인하는 데 필요한 코드 만 포함되도록 예제를 줄이십시오. 입력 한 코드가 너무 길어요. (그렇게함으로써 오류의 원인을 스스로 찾아 낼 수도 있습니다.) – krlmlr