piscine/c12/ex08/ft_list_reverse.c
Willem Haffmans 607ce08c18 all
2024-09-10 00:18:01 +02:00

32 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_list_reverse.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/03 15:22:55 by whaffman #+# #+# */
/* Updated: 2024/07/03 17:38:50 by whaffman ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_list.h"
void ft_list_reverse(t_list **begin_list)
{
t_list *prev;
t_list *curr;
t_list *next;
curr = *begin_list;
prev = NULL;
while (curr)
{
next = curr->next;
curr->next = prev;
prev = curr;
curr = next;
}
*begin_list = prev;
}