Seemingly fixed the logic
This commit is contained in:
parent
70c14170fa
commit
50295427c8
@ -61,18 +61,19 @@ struct car* clear_train(struct car* first, const char* target) {
|
|||||||
return first;
|
return first;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
struct car* prev= NULL;
|
||||||
struct car* temp = first;
|
struct car* temp = first;
|
||||||
struct car* next = first->next;
|
while (temp->next)
|
||||||
while (next->next)
|
{
|
||||||
{if(strcmp(next->value, target) == 0){
|
prev = temp;
|
||||||
next->next = NULL;
|
temp = temp->next;
|
||||||
temp->next = next->next;
|
if(strcmp(temp->value, target) == 0){
|
||||||
free(next);
|
|
||||||
|
prev->next = temp->next;
|
||||||
|
free(temp);
|
||||||
|
temp = prev->next;
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
temp = next;
|
|
||||||
next = next->next;}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user