From 6b862ba9d737ca0f3c99371e95280b2e9b591d5f Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Tue, 3 Nov 2020 21:31:24 +0100 Subject: [PATCH] clear --- cv5/a_train.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index 3056cd4..c18af36 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -84,10 +84,12 @@ struct car* clear_train(struct car* first, const char* target) { while(this != NULL){ int x = strcmp(this->value, target); if(x == 0){ + first = this->next; + free(this) this->next = NULL; //free(this->next); - return this; + return first; } this = this->next; }