This commit is contained in:
Maryna Kravtsova 2020-11-03 18:30:23 +01:00
parent 3ff32fafa1
commit 97472d25cf

View File

@ -64,11 +64,16 @@ struct car* clear_train(struct car* first, const char* target) {
while(first != NULL){
int x = strcmp(this->value, target);
if(x == 0){
struct car* temp = this->next;
strcpy(this->value,temp->value);
free(temp);
free(temp->value);
return 0;
struct car* prev = this;
struct car* node = this->next;
while(prev != NULL && node != NULL){
prev->next = node->next;
free(node);
prev = prev->next;
if(prev != NULL){
node = prev->next;
}
}
}
this = this->next;
}