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
+9 -4
View File
@@ -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;
}
+3 -3
View File
@@ -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);
+1 -1
View File
@@ -51,6 +51,6 @@ int main()
clear();
printf("Done\n");
return 1;
}