This commit is contained in:
Alina Konoval 2025-11-06 20:58:45 +01:00
parent be3d77502c
commit b9d90d148d

View File

@ -31,11 +31,15 @@ void print_train(struct car* first) {
}
void cancel_train(struct car* first) {
if (first == NULL) return;
cancel_train(first->next);
while (first) {
struct car* next = first->next;
first->next = NULL; // ochrana proti cyklom alebo neplatnému next
free(first);
first = next;
}
}
struct car* clear_train(struct car* first, const char* name) {
// Ak je zoznam prázdny