clear train

This commit is contained in:
Valér Jakubčo 2021-11-04 20:14:54 +01:00
parent 7d8b479f1c
commit a4e02b775f

View File

@ -40,6 +40,9 @@ void cancel_train(struct car* first) {
struct car* clear_train(struct car* first, const char* target) { struct car* clear_train(struct car* first, const char* target) {
struct car* this = first; struct car* this = first;
if (this == NULL){
return NULL;
}
while( this->next->next != NULL){ while( this->next->next != NULL){
if(strcmp(this->value, target) == 0){ if(strcmp(this->value, target) == 0){
this->next == this->next->next; this->next == this->next->next;