diff --git a/cv5/a_train.c b/cv5/a_train.c index 109545e..6f86beb 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -78,9 +78,9 @@ struct car* clear_train(struct car* first, const char* target) { while(this != NULL){ int x = strcmp(this->value, target); if(x == 0){ - struct car *third = this->next->next; - free(this->next); - this->next = third; + struct car *third = this->next; + this->next = third->next; + free(third); return first; } this = this->next;