From 9d3a3489bbf5ff4b696ab3a2d2dfc4c057fff004 Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Tue, 3 Nov 2020 17:58:39 +0100 Subject: [PATCH] clear --- cv5/a_train.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index 3e5b1f2..baf72b4 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -30,16 +30,6 @@ void print_train(struct car* first) { for(struct car* this = first; this != NULL; this = this->next){ printf("%s\n", this->value); } - /*struct car* this = first; - if(first == NULL){ - exit(0); - } - else{ - while(this != NULL){ - printf("%s\n", this->value); - this = this->next; - } - }*/ } void cancel_train(struct car* first) { @@ -52,10 +42,7 @@ void cancel_train(struct car* first) { } else if(first->next == NULL){ free(first); - // cancel_train(first->next); } - //free(first); - } @@ -74,11 +61,11 @@ struct car* clear_train(struct car* first, const char* target) { } else{ struct car* this = first; - while(this != NULL){ + while(first != NULL){ int x = strcmp(this->value, target); if(x == 0){ struct car* temp = this->next; - this->value = temp->value; + strcpy(this->value,temp->value); free(temp); return 0; }