From 468b37d1bef1402adbce2a83e621002cedf77c2b Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Thu, 5 Nov 2020 15:46:53 +0100 Subject: [PATCH] clear --- cv5/a_train.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index 3365ec0..7a9aa9a 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -72,13 +72,12 @@ struct car* clear_train(struct car* first, const char* target) { } x = strcmp(prev->next->value, target); - // if(x == 0){ - /* if(first->next->next == NULL) { - //struct car* tmp = prev->next; - free(prev->next); - prev->next = NULL; - }*/ - //} + if(x == 0){ + struct car* third = prev->next->next; + free(prev->next); + prev->next = third; + + } prev = prev->next; } if(prev->next->next == NULL) { @@ -89,6 +88,13 @@ struct car* clear_train(struct car* first, const char* target) { return prev; } + x = strcmp(prev->next->value, target); + if(x == 0){ + struct car* third = prev->next->next; + free(prev->next); + prev->next = third; + } + //free(prev->next); //prev->next = NULL; }