views:

24

answers:

1

Hello, I've got some problem with my function and don't know how to solve this problem, This is my code:

ListResult result=listFind(currentLines, compareBasicLines, &linePrototype);  <-here problem

compareBasicLines pointer to function

int compareBasicLines(ptrLine line1, ptrLine line2){
    COMPARE_NUMBER_STRINGS(line1, line2);
}

COMPARE_NUMBER_STRINGS(line1, line2); defined in another file

#define COMPARE_NUMBER_STRINGS(var1, var2)                              \
                    if(var1 == NULL || var2 == NULL){                   \
                        return 0;                                       \
                    }                                                   \
                    return strcmp(var1->strNumber, var2->strNumber);

thanks in advance for everyone

this is what I have, my homework is about ADT, so I don't know what exacly do I have inside listFind

/**
 * Searches the list for an element fitting the criteria starting from the
 * current element.
 * Note that you need to call listGetFirst if you wish to search from the start
 * of the list. The search starts from the current element.
 * @param list
 *  The list to search in
 * @param compare
 *  Comparison function to decide if an element in the last is equal to the
 *  target elemnt. This function should return 0 for equal elements
 * @param target
 *  A target element to compare with each element in the list.
 * @return
 *  LIST_NULL_ARGUMENT if list or compare are NULL
 *  LIST_INVALID_CURRENT if the current pointer of the list is in invalid state
 *  LIST_NO_SUCH_ELEMENT if no element was found from the current element until
 *  the end of the list
 *  LIST_SUCCESS an element was found and the current pointer of the list is now
 *  set to this element
 *
 */

ListResult listFind(List list, CompareListElements compare, ListElement target);

and one more definition

typedef int (*CompareListElements)(ListElement, ListElement);

typedef void* ListElement;
A: 

Your second argument to listFind() is of type int (*)(ptrLine, ptrLine). That is evidently different from the type of the second parameter in the declaration of listFind().

Without seeing the definition of listFind(), it's hard to say what you should do to fix it.

caf