网站建设需要掌握什么知识,静态网站的短处,三亚文明城市建设服务中心报名网站,凡科网站产品导航怎么做1、问题 通过函数指针实现在链表中找到特定的值,这里可以是int 类型或者char *类型 思路: 整形数据自己写比较函数,字符串比较用strcmp,然后把这个函数指针传递到函数作为参数。 2、代码实现 #include stdio.h
#include string.htypedef struct No…1、问题
通过函数指针实现在链表中找到特定的值,这里可以是int 类型或者char *类型 思路: 整形数据自己写比较函数,字符串比较用strcmp,然后把这个函数指针传递到函数作为参数。 2、代码实现 #include stdio.h
#include string.htypedef struct Node
{struct Node *next;char value[100];//int value;
} Node;//在链表中查找找到制定的值
Node *search_list(Node *node, void const *value, int (*compare)(void const *, void const *))
{while (node != NULL){if (compare((node-value), value) == 0){printf("hello");return node;}node = node-next;}return NULL;
}int compare_int(void const *a, void const *b)
{if (*(int *)a == *(int *)b)return 0;elsereturn 1;
}int main()
{Node node1, node2, node3, node4, node5;strcpy(node