uprava podmienky

This commit is contained in:
Valér Jakubčo 2021-11-04 20:46:01 +01:00
parent a66b22631d
commit 0510e66518

View File

@ -51,6 +51,13 @@ 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){
free(this);
this->next=NULL;
return this;
}
}
while( this->next->next != NULL){ while( this->next->next != NULL){
if(strcmp(this->value, target) == 0){ if(strcmp(this->value, target) == 0){
free(this->next); free(this->next);
@ -61,12 +68,5 @@ struct car* clear_train(struct car* first, const char* target) {
this = this->next; this = this->next;
} }
} }
if(strcmp(this->value, target) ==0){ return first;
free(this);
this->next = NULL;
return this;
}
else{
return first;
}
} }