From a8b464877864b34e004bdb34a4b3347e8dae70ff Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Tue, 3 Nov 2020 21:49:22 +0100 Subject: [PATCH] clear --- cv5/a_train.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index d8fc8bc..5415679 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -80,16 +80,14 @@ struct car* clear_train(struct car* first, const char* target) { else{ struct car* this = first; - while(this != NULL){ + while(this->next != NULL){ //while(this != NULL){ - int x = strcmp(this->value, target); + int x = strcmp(this->next->value, target); if(x == 0){ - first = this->next; - free(this); + struct car* temp = this->next->next; this->next = NULL; - //free(this->next); - - return first; + this->next = temp; + return this; } this = this->next; //}