gpt4 book ai didi

c - 从不兼容的指针类型传递 arg2 'listFind'

转载 作者:行者123 更新时间:2023-11-30 19:50:27 24 4
gpt4 key购买 nike

我的函数有一些问题,不知道如何解决这个问题,这是我的代码:

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

compareBasicLines 函数指针

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

COMPARE_NUMBER_STRINGS(line1, line2); 在另一个文件中定义

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

提前感谢大家

这就是我所拥有的,我的作业是关于ADT的,所以我不知道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);

还有一个定义

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

typedef void* ListElement;

最佳答案

listFind() 的第二个参数的类型为 int (*)(ptrLine, ptrLine)。这与listFind()声明中第二个参数的类型明显不同。

如果没有看到listFind()的定义,很难说你应该做什么来修复它。

关于c - 从不兼容的指针类型传递 arg2 'listFind',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2816969/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com