following to this previous question about Void * on double linked lists I'm now wondering on how implement a find function that handles with this type of linked list. i made some steps forward with this and i'm a bit confused.. the base idea is the following
void find(list_el *el, linked_list *l_ptr )
{
list_el *p = l_ptr->head;
while(p != NULL)
{
if ((l_ptr->data_compare_func(el->data,p->data)) == 0) /* 0 means exact match*/
{
printf("Found\n");
}
p = p->next;
}
}
as it is now written is wrong but i can't do better than this because I do not have a clear idea of how this works. I'd like to make it dynamic and i do not have ideas on how is the better way to handle the el parameter... should i declare it as list_el or should i declare it as void* ? a problem could be that if i declare it as list_el every time i have to call find i have to create a new list_el fill it and pass it to the find method. i think it's not a good way..for the "void * solution " i don't know if it will change something perhaps it would be even worse... as you can deduce from my ramblings are very confused any help will be useful..
Thanks