From e1a3d77eac305703f7f57cb863f13a18c83fdf45 Mon Sep 17 00:00:00 2001 From: vj586da Date: Thu, 4 Nov 2021 20:17:06 +0100 Subject: [PATCH] clear train --- cv4/a_train.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cv4/a_train.c b/cv4/a_train.c index db20e3a..cbd4b57 100755 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -43,6 +43,14 @@ struct car* clear_train(struct car* first, const char* target) { if (this == NULL){ return NULL; } + if (this->next == NULL){ + if(strcmp(this->value, target) == 0){ + free(this); + return NULL; + }else { + return first; + } + } while( this->next->next != NULL){ if(strcmp(this->value, target) == 0){ this->next == this->next->next;