2013-04-30 2 views
2

값이 이미있는 경우 Integer가있는 요소의 연결된 목록을 확인하고 싶습니다.C : 충돌 유형 오류

struct ListenElement{ 
    int wert; 
    struct ListenElement *nachfolger; 
}; 

struct ListenAnfang{ 
    struct ListenElement *anfang; 
}; 

struct ListenAnfang LA; 

bool ckeckForInt(int value){ 
    if (LA.anfang == NULL){ 
     return 0; 
    } 
    return checkCurrent(LA.anfang, value); 
} 

bool checkCurrent(struct ListenElement* check, int value){ 
    if (check->wert == value){ 
     return true; 
    } 
    else if (check->nachfolger != NULL){ 
     return checkCurrent(check->nachfolger, value); 
    } 
    else{ 
     return false; 
    } 
} 

나는 checkCurrent 메서드에 대해 충돌하는 형식을 가져 오지만 찾을 수 없습니다.

답변

4

함수 선언이 누락되었습니다. C에서 함수를 그대로 선언해야합니다.

struct ListenElement{ 
    int wert; 
    struct ListenElement *nachfolger; 
}; 

struct ListenAnfang{ 
    struct ListenElement *anfang; 
}; 

struct ListenAnfang LA; 

//The function declaration ! 
bool checkCurrent(struct ListenElement* check, int value); 

bool ckeckForInt(int value){ 
    if (LA.anfang == NULL){ 
     return 0; 
    } 
    return checkCurrent(LA.anfang, value); 
} 

bool checkCurrent(struct ListenElement* check, int value){ 
    if (check->wert == value){ 
     return true; 
    } 
    else if (check->nachfolger != NULL){ 
     return checkCurrent(check->nachfolger, value); 
    } 
    else{ 
     return false; 
    } 
} 
4

checkCurrent()는 음함수 선언 결과가 선언하거나 정의 전에 (타입 bool를 반환 갖는 함수의 정의와 동일하지 않다) int 리턴 형으로 생성되는 사용되고 .

bool checkCurrent(struct ListenElement* check, int value); 

bool ckeckForInt(int value){ 
    if (LA.anfang == NULL){ 
     return false; /* Changed '0' to 'false'. */ 
    } 
    return checkCurrent(LA.anfang, value); 
} 

또는 이전 checkForInt()에 정의를 이동 : checkCurrent() 이전에 최초의 사용에 대한 선언을 추가합니다.