示例:
- //定义回调函数原型
- typdef void (*PrintCallBack) (List* node, void* user_data);
- void list_print (List* list, PrintCallBack cb, void* user_data)
- {
- if (!list) return;
- List* node = list_first (list);
- while (node)
- {
- //将链表数据和用户数据传给回调函数,用户数据的作用是让应用传递一些额外的数据
- cb (node, user_data);
- node = node->next;
- }
- }
- //回调函数实例
- void print_int (List* node, void* user_data)
- {
- printf ("%d/n", node->data);
- }
5623



被折叠的 条评论
为什么被折叠?



