This commit is contained in:
Maryna Kravtsova 2020-11-02 14:48:59 +01:00
parent df034f6c6d
commit 61443227a5

View File

@ -1,4 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -43,9 +44,10 @@ void cancel_train(struct car* first) {
return; return;
} }
else if(first->next != NULL){ else if(first->next != NULL){
cancel_train(first->next); struct car* help = first->next;
first->next = NULL;
free(first); free(first);
cancel_train(help);
//first->next = NULL;
} }
else if(first->next == NULL){ else if(first->next == NULL){
free(first); free(first);