From f7ca4276c393f5ba49223d03c81bb5f10143e5d6 Mon Sep 17 00:00:00 2001 From: kr820js Date: Sat, 13 Apr 2024 19:26:17 +0200 Subject: [PATCH] submit3 --- cv9/snake.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cv9/snake.c b/cv9/snake.c index d4f4ec8..cd0248a 100644 --- a/cv9/snake.c +++ b/cv9/snake.c @@ -15,16 +15,20 @@ struct snake* remove_snake(struct snake* snake){ return NULL; } struct snake* curent_element = snake; + struct snake* previous_element; while(curent_element->next != NULL){ + previous_element=curent_element; curent_element = curent_element->next; } - + free(curent_element); - + if(curent_element==snake){ return NULL; } + previous_element->next=NULL; + return snake; }