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