From 0510e665189b08bb35393fd464cb470e9ef8a582 Mon Sep 17 00:00:00 2001 From: vj586da Date: Thu, 4 Nov 2021 20:46:01 +0100 Subject: [PATCH] uprava podmienky --- cv4/a_train.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index 06f53de..8880447 100755 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -51,6 +51,13 @@ struct car* clear_train(struct car* first, const char* target) { return this; } } + if(this->next->next == NULL){ + if(strcmp(this->value, target) == 0){ + free(this); + this->next=NULL; + return this; + } + } while( this->next->next != NULL){ if(strcmp(this->value, target) == 0){ free(this->next); @@ -61,12 +68,5 @@ struct car* clear_train(struct car* first, const char* target) { this = this->next; } } - if(strcmp(this->value, target) ==0){ - free(this); - this->next = NULL; - return this; - } - else{ - return first; - } + return first; }