list change

This commit is contained in:
Remco
2016-03-30 20:17:58 +02:00
parent b19dac39e8
commit d127cbe3bf
3 changed files with 13 additions and 8 deletions
+8 -3
View File
@@ -116,9 +116,13 @@ void show()
} }
else else
{ {
for (; NULL != p->next; p = p->next) while (1)
{ {
printf("node nr: %d heeft data [%d]\n", nr++, p->data); printf("node nr: %d heeft data [%d]\n", nr++, p->data);
if (p->next == NULL)
break;
p = p->next;
} }
} }
} }
@@ -195,6 +199,7 @@ int remove(int begin)
int removePos(int positie) int removePos(int positie)
{ {
int i;
if (positie == 0) if (positie == 0)
{ {
remove(1); remove(1);
@@ -207,8 +212,8 @@ int removePos(int positie)
{ {
struct node *r = pStart; //the node you want to remove struct node *r = pStart; //the node you want to remove
/*looping till you got to the positie, and save the node*/ /*looping till you got to the positie, and save the node*/
for (int i = 0; i < (positie - 1); i++) for (i = 0; i < (positie - 1); i++)
{ {
r = r->next; r = r->next;
} }
+3 -3
View File
@@ -12,9 +12,9 @@ struct node
void init(); void init();
int add(int data, int begin); int add(int data, int begin);
int addPos(int data, int positie); int addPos(int data, int positie);
void show(); void show(void);
void clear(); void clear(void);
int length(); int length(void);
int exists(int data); int exists(int data);
int remove(int); int remove(int);
int removePos(int); int removePos(int);