i need a function that checks in two linked lists are equal thi is what i have so far
bool equal(list L1 , list L2 , int (*p_cmp_f)() ){
if( L1==NULL && L2==NULL)
return TRUE;
else if( L1==NULL || L2==NULL)
return FALSE;
else if( (*p_cmp_f)(L1->data,L2->data) == -1)
return FALSE;
else
equal(L1->next,L2->next) ;
return TRUE;
}
so this is basically how i define a node
struct node { generic_ptr datapointer; list next; };
i basically define a list as a pointer to a node
so a node has a datapointer field and a next field which is basically pointing to another node since a list is a pointer to a node
so the first time im passing the two lists and a compare function
here is the compare function =
int compare_int( generic_ptr x , generic_ptr y){
if( *(int*) x < *(int *)y ) return -1 ;
if( *(int*) x > *(int *)y ) return 1 ;
return 0 ;
}
rockerjhr -3 Junior Poster in Training
Adak 419 Nearly a Posting Virtuoso
abhimanipal 91 Master Poster
rockerjhr -3 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.