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

bugfixes

parent 5fb1e561
......@@ -4,10 +4,10 @@ test : test.out
.PHONY : run compile test
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
gcc -o main.out llist.c main.c
gcc -std=c99 -o main.out llist.c main.c
compile : test.out main.out
......
......@@ -22,7 +22,7 @@ void print_list(NODE *head){
int i = 0;
while (currentNode->data != NULL){
while (currentNode != NULL){
printf("Index: %d; Data: %d\n",i,currentNode->data);
currentNode=currentNode->next;
i++;
......@@ -30,14 +30,14 @@ void print_list(NODE *head){
}
NODE* search(int n, NODE *head){
printf("Searching list for: %d", n);
NODE* search(NODE *head, int pos){
printf("Searching list for: %d", pos);
NODE *currentNode;
currentNode = head;
while (currentNode->data != NULL){
if(currentNode->data == n){
while (currentNode != NULL){
if(currentNode->data == pos){
printf("Location found, index: %d.", currentNode);
return currentNode;
}
......@@ -87,7 +87,7 @@ NODE *construct_list(datatype list[], int size){
head = next;
next = construct(list[i],head);
if(next == NULL)
Delete_List(head);
delete_list(head);
}
return next;
}
......
......@@ -14,7 +14,7 @@ typedef struct Node_Err
void print_node(NODE *head, int pos);
void print_list(NODE *head);
NODE* search(int n, NODE *head);
NODE *search(NODE *head, datatype data);
NODE *construct(datatype data, NODE *next);
NODE *traverse(NODE *head, int pos);
int delete_node_after(NODE *head);
......@@ -22,5 +22,4 @@ NODE *construct_list(datatype list[], int size);
int add_to_end(NODE *head, datatype new_data);
int insert_node(NODE *head, int pos, datatype new_data);
int insert_node_after(NODE *head, datatype data);
NODE *search(NODE *head, datatype data);
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