diff --git a/C-RK/C-RK-Week2/llist.c b/C-RK/C-RK-Week2/llist.c index c63dbb4..dec2555 100644 --- a/C-RK/C-RK-Week2/llist.c +++ b/C-RK/C-RK-Week2/llist.c @@ -116,9 +116,13 @@ void show() } else { - for (; NULL != p->next; p = p->next) + while (1) { printf("node nr: %d heeft data [%d]\n", nr++, p->data); + if (p->next == NULL) + break; + + p = p->next; } } } @@ -184,7 +188,7 @@ int remove(int begin) pStart = p; } else - { + { p = pEnd->previous; p->next = NULL; free(pEnd); @@ -195,6 +199,7 @@ int remove(int begin) int removePos(int positie) { + int i; if (positie == 0) { remove(1); @@ -207,8 +212,8 @@ int removePos(int positie) { struct node *r = pStart; //the node you want to remove - /*looping till you got to the positie, and save the node*/ - for (int i = 0; i < (positie - 1); i++) + /*looping till you got to the positie, and save the node*/ + for (i = 0; i < (positie - 1); i++) { r = r->next; } diff --git a/C-RK/C-RK-Week2/llist.h b/C-RK/C-RK-Week2/llist.h index c0c44a0..fd934c3 100644 --- a/C-RK/C-RK-Week2/llist.h +++ b/C-RK/C-RK-Week2/llist.h @@ -12,9 +12,9 @@ struct node void init(); int add(int data, int begin); int addPos(int data, int positie); -void show(); -void clear(); -int length(); +void show(void); +void clear(void); +int length(void); int exists(int data); int remove(int); int removePos(int); diff --git a/C-RK/C-RK-Week2/main.c b/C-RK/C-RK-Week2/main.c index 3fa64d6..9ee5bc8 100644 --- a/C-RK/C-RK-Week2/main.c +++ b/C-RK/C-RK-Week2/main.c @@ -51,6 +51,6 @@ int main() clear(); printf("Done\n"); - + return 1; }