From a6861c0d999cb055771730b243f23de4515d3862 Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Tue, 3 Nov 2020 10:40:44 +0100 Subject: [PATCH] clear --- cv5/a_train.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index ff8d71d..6a68c9d 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -64,9 +64,12 @@ void cancel_train(struct car* first) { struct car* clear_train(struct car* first, const char* target) { if(first == NULL){ return 0; - } + } + int result = 0; + if(first->next == NULL){ - if(first->value == target){ + x = strcmp(first->value, target); + if(x == 0){ free(first); return 0; } @@ -74,7 +77,9 @@ struct car* clear_train(struct car* first, const char* target) { else{ struct car* this = first; while(this != NULL){ - if(this->value == target){ + int x == strcmp(this->value, target); + if(x == 0){ + free(this->value); return 0; } this = this->next;