From b0037f417c81b27f423afd8e8e9351c18c9b9361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Vasi=C4=BE?= Date: Tue, 26 Apr 2022 21:41:30 +0200 Subject: [PATCH] domaca_uloha_7 --- du7/snake.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/du7/snake.c b/du7/snake.c index d837b78..21a3077 100644 --- a/du7/snake.c +++ b/du7/snake.c @@ -27,11 +27,10 @@ struct snake* remove_snake(struct snake* snake){ struct snake* medzipamat = calloc(1, sizeof(struct snake)); medzipamat = snake; - while (1) { - snake = snake->next; - if (snake->next->next == NULL) break; - } + while (snake->next->next != NULL) snake = snake->next; + free(snake->next); + snake->next = NULL; snake = medzipamat;