-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstlast.c
33 lines (30 loc) · 1.25 KB
/
ft_lstlast.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstlast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tiagalex <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/08 12:27:29 by tiagalex #+# #+# */
/* Updated: 2024/11/08 13:05:00 by tiagalex ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
//retorna o ultimo node da lista
t_list *ft_lstlast(t_list *lst)
{
if (lst == NULL)
return (NULL);
while (lst->next != NULL)
lst = lst->next;
return (lst);
}
/*
int main()
{
t_list *lst = ft_lstnew("banana");
ft_lstadd_front(&lst,ft_lstnew("manga"));
ft_lstadd_front(&lst,ft_lstnew("ananas"));
printf("%s", (char *)ft_lstlast(lst)->content);
return (0);
} */