From 22b91c853b1bd63d511fa7d4d4d1ea52b9507642 Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Tue, 3 Nov 2020 10:32:01 +0100 Subject: [PATCH] clear --- cv5/a_train.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index df64671..931ea59 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -74,16 +74,12 @@ struct car* clear_train(struct car* first, const char* target) { } } else{ - struct car* prev = first; - while(prev->next->next != NULL){ - x = strcmp(prev->next->value, target); - if(x == 0){ - struct car* third = prev->next->next; - free(prev->next); - break; + struct car* this = first; + while(this != NULL){ + if(this->value == target){ + return 0; } - prev = prev->next; - + this = this->next; } } return first;