diff --git a/main.tsk b/main.tsk index edb62fd..3f0abe3 100644 --- a/main.tsk +++ b/main.tsk @@ -1,3 +1,3 @@ *Compile #do -gcc -o tasks -I src src/tasks.c \ No newline at end of file +gcc -g -o tasks -I src src/tasks.c \ No newline at end of file diff --git a/src/tasks.c b/src/tasks.c index 2fe69a2..b7a0f8e 100644 --- a/src/tasks.c +++ b/src/tasks.c @@ -29,8 +29,18 @@ void TASKS_sll_print(TASKS_str_linked_list *list){ void TASKS_sll_add(TASKS_str_linked_list **list, char *s){ TASKS_str_linked_list *node = (TASKS_str_linked_list *) malloc(sizeof(TASKS_str_linked_list)); node->data = s; - node->next = *list; - *list = node; + node->next = NULL; + TASKS_str_linked_list *iterator = *list; + + if (iterator == NULL){ + //This is the first element added to list + *list = node; + return; + } + + while(iterator->next != NULL) + iterator = iterator->next; + iterator->next = node; } // The length values will also count \0