diff --git a/cv5/a_train.c b/cv5/a_train.c index 40281eb..3e5b1f2 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -1,5 +1,4 @@ #include - #include #include @@ -78,10 +77,9 @@ struct car* clear_train(struct car* first, const char* target) { while(this != NULL){ int x = strcmp(this->value, target); if(x == 0){ - this->value = this->next->value; - struct car* third = this->next; - this->next = third->next; - free(third); + struct car* temp = this->next; + this->value = temp->value; + free(temp); return 0; } this = this->next;