I have a compare function which receives at different times either first name, last name and maybe even both? Initially when wrote my lab it was only for the first name..how do I modify the code to accomodate for both first name or last name..(first name and last name are fields in the KEY structure of a linked list)..any ideas?
strcture KEY contains an array for first names and another array for last names..
This was my initial code..how do I modify it?
and this is my search function that gets first name OR last name OR both..
int cmp(KEY k, KEY k2)
int cmp = 0;
cmp = strcmp(k.names, k2.names);
Currently, this search function works just fine if I want to look up the directory using first names..need to modify it so that I can search using last names as well. Any ideas?
int searchList(NODE *pList,
int found = 0;
*pPre = NULL;
*pCur = pList;
while(*pCur != NULL && (cmp(k, (*pCur)->directory.k) > 0))
*pPre = *pCur;
*pCur = (*pCur)-> next;
if(*pCur && (cmp(k, (*pCur)->directory.k) == 0))
found = 1;
The main idea behind the code is that it should be generic. Thats what the purpose of the project is: to recycle code..