From 20fc5fc559485f3a733254098461f7937b63866f Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Tue, 27 Oct 2020 18:18:34 +0100 Subject: [PATCH] train2 --- cv5/a_train.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index 99d4d0b..2d9a33d 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -32,18 +32,22 @@ void print_train(struct car* first) { } void cancel_train(struct car* first) { + struct car* this; if(first == NULL){ exit(0); } - if(first->value == NULL){ - //struct car *this = first->next; - free(first); + else{ + this = first; + first = this->next; + free(this); + cancel_train(first->next); + free(first); + } - cancel_train(first->next); - free(first); } + struct car* clear_train(struct car* first, const char* target) { struct car* this = first; while(this != NULL){