Commit 9f539681 authored by Liam E. Roeth's avatar Liam E. Roeth

bugfixes

parent 5fb1e561
...@@ -4,10 +4,10 @@ test : test.out ...@@ -4,10 +4,10 @@ test : test.out
.PHONY : run compile test .PHONY : run compile test
test.out : llist.c llist.h main.c test.out : llist.c llist.h main.c
gcc -o test.out llist.c test.c gcc -std=c99 -o test.out llist.c test.c
main.out : llist.c llist.h main.c main.out : llist.c llist.h main.c
gcc -o main.out llist.c main.c gcc -std=c99 -o main.out llist.c main.c
compile : test.out main.out compile : test.out main.out
......
...@@ -22,7 +22,7 @@ void print_list(NODE *head){ ...@@ -22,7 +22,7 @@ void print_list(NODE *head){
int i = 0; int i = 0;
while (currentNode->data != NULL){ while (currentNode != NULL){
printf("Index: %d; Data: %d\n",i,currentNode->data); printf("Index: %d; Data: %d\n",i,currentNode->data);
currentNode=currentNode->next; currentNode=currentNode->next;
i++; i++;
...@@ -30,14 +30,14 @@ void print_list(NODE *head){ ...@@ -30,14 +30,14 @@ void print_list(NODE *head){
} }
NODE* search(int n, NODE *head){ NODE* search(NODE *head, int pos){
printf("Searching list for: %d", n); printf("Searching list for: %d", pos);
NODE *currentNode; NODE *currentNode;
currentNode = head; currentNode = head;
while (currentNode->data != NULL){ while (currentNode != NULL){
if(currentNode->data == n){ if(currentNode->data == pos){
printf("Location found, index: %d.", currentNode); printf("Location found, index: %d.", currentNode);
return currentNode; return currentNode;
} }
...@@ -87,7 +87,7 @@ NODE *construct_list(datatype list[], int size){ ...@@ -87,7 +87,7 @@ NODE *construct_list(datatype list[], int size){
head = next; head = next;
next = construct(list[i],head); next = construct(list[i],head);
if(next == NULL) if(next == NULL)
Delete_List(head); delete_list(head);
} }
return next; return next;
} }
......
...@@ -14,7 +14,7 @@ typedef struct Node_Err ...@@ -14,7 +14,7 @@ typedef struct Node_Err
void print_node(NODE *head, int pos); void print_node(NODE *head, int pos);
void print_list(NODE *head); void print_list(NODE *head);
NODE* search(int n, NODE *head); NODE *search(NODE *head, datatype data);
NODE *construct(datatype data, NODE *next); NODE *construct(datatype data, NODE *next);
NODE *traverse(NODE *head, int pos); NODE *traverse(NODE *head, int pos);
int delete_node_after(NODE *head); int delete_node_after(NODE *head);
...@@ -22,5 +22,4 @@ NODE *construct_list(datatype list[], int size); ...@@ -22,5 +22,4 @@ NODE *construct_list(datatype list[], int size);
int add_to_end(NODE *head, datatype new_data); int add_to_end(NODE *head, datatype new_data);
int insert_node(NODE *head, int pos, datatype new_data); int insert_node(NODE *head, int pos, datatype new_data);
int insert_node_after(NODE *head, datatype data); int insert_node_after(NODE *head, datatype data);
NODE *search(NODE *head, datatype data);
int length(NODE *head); int length(NODE *head);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment