This commit is contained in:
Maryna Kravtsova 2020-11-02 11:44:42 +01:00
parent fdde562ecf
commit 3ec3997cd6

View File

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