From ce3648c65b87b09e2c3395a2edc9e847c101fcb4 Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Tue, 3 Nov 2020 10:46:03 +0100 Subject: [PATCH] clear --- cv5/a_train.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index 2f5803b..109545e 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -77,9 +77,11 @@ struct car* clear_train(struct car* first, const char* target) { struct car* this = first; while(this != NULL){ int x = strcmp(this->value, target); - if(x == 0){ - free(this->value); - return 0; + if(x == 0){ + struct car *third = this->next->next; + free(this->next); + this->next = third; + return first; } this = this->next; }