This commit is contained in:
Maryna Kravtsova 2020-10-27 17:37:53 +01:00
parent 7be122a19c
commit 96151e5e3b

View File

@ -15,8 +15,7 @@ struct car* add_car(struct car* first,const char* target) {
this = this->next; this = this->next;
} }
this->next = newcar; this->next = newcar;
return first; return first;
} }
void print_train(struct car* first) { void print_train(struct car* first) {
@ -32,18 +31,15 @@ void print_train(struct car* first) {
} }
} }
void cancel_train(struct car* first) { void cancel_train(struct car* first) {
struct car *this = first->next;
if(first == NULL){ if(first == NULL){
exit(0); exit(0);
} }
if(first->next == NULL){ if(first->value == NULL){
struct car *this = first; free(first);
first = first->next;
free(this);
exit(0);
} }
cancel_train(first->next); cancel_train(this->next);
free(first); free(first);
} }