This commit is contained in:
Valér Jakubčo 2021-11-05 08:41:35 +01:00
parent 1b5c0f5406
commit ab0afef8a3

View File

@ -51,17 +51,6 @@ struct car* clear_train(struct car* first, const char* target) {
return this; return this;
} }
} }
/*if(this->next->next == NULL){
if(strcmp(this->value, target) == 0){
struct car* tmp = this->next;
free(this);
return tmp;
}else if(strcmp(this->next->value, target) == 0){
free(this->next);
this->next=NULL;
return this;
}
}*/
while( this->next->next != NULL){ while( this->next->next != NULL){
if(strcmp(this->next->value, target) == 0){ if(strcmp(this->next->value, target) == 0){
struct car* third = this->next->next; struct car* third = this->next->next;
@ -80,7 +69,7 @@ struct car* clear_train(struct car* first, const char* target) {
}else if(strcmp(this->next->value, target) == 0){ }else if(strcmp(this->next->value, target) == 0){
free(this->next); free(this->next);
this->next=NULL; this->next=NULL;
return this; return first;
} }
return first; return first;
} }