This commit is contained in:
Maryna Kravtsova 2020-11-02 11:54:55 +01:00
parent c80a5ff82d
commit cd83aa7005

View File

@ -32,24 +32,16 @@ void print_train(struct car* first) {
}
void cancel_train(struct car* first) {
struct car* this = first;
if(first == NULL){
exit(0);
}
if(this->next == NULL){
this = first->next;
free(first);
this = NULL;
struct car* this = first;
first = first->next;
free(this);
first = NULL;
}
else{
/*struct car* prev = first;
while(prev->next->next != NULL){
prev = prev->next;
}
this = prev->next;
prev->next = NULL;
free(this);*/
else{
cancel_train(first->next);
free(first);
}