//linkedListLib4.c //John T. Rine //October 6, 2011 //lab46:~$ gcc -c linkedListLib.c -o linkedListLib.o //lab46:~$ ar crs liblinkedListLib.a linkedListLib.o //lab46:~$ gcc -I. linkedListTest.c -o linkedListTest liblinkedListLib.a #include #include //#include"linkedListLib4.h" #include"linkedListLib.h" void loadNode(node *head, int position, int value) { int i; node *temp = NULL; temp = head; temp = head; for(i = 0; i < position; i++) { temp = temp->next; } temp->data = value; } void createNode(node* head, node* tail) { head = (node *) malloc(sizeof(node)); tail = head; head->prev = NULL; head->next = NULL; } void copyList(node *head, node **copyHead, node **copyTail) { node *new, *temp; new = *copyHead = *copyTail = temp = NULL; temp = head; while(temp != NULL) { if (*copyHead == NULL) { *copyHead = (node *) malloc(sizeof(node)); *copyTail = *copyHead; (*copyHead)->prev = NULL; (*copyHead)->next = NULL; (*copyHead)->data = temp->data; } else { new = (node *) malloc(sizeof(node)); new->prev = *copyTail; new->next = NULL; (*copyTail)->next = new; *copyTail = new; (*copyTail)->data = temp->data; } temp = temp->next; } } int findData(node *head, int data) { int counter = 0; while(head != NULL) { if(head->data == data) break; counter++; head = head->next; } return counter; }