-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstlast.c
41 lines (36 loc) · 1.39 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
34
35
36
37
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstlast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nmattera <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/20 17:57:55 by nmattera #+# #+# */
/* Updated: 2022/05/21 15:42:21 by nmattera ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstlast(t_list *lst)
{
if (!lst)
return (NULL);
while (lst->next)
lst = lst->next;
return (lst);
}
/* #include <stdio.h>
int main()
{
t_list *lst;
t_list *new;
t_list *test;
t_list *last;
lst = ft_lstnew("bim");
new = ft_lstnew("stir");
test = ft_lstnew("go");
ft_lstadd_front(&lst, new);
ft_lstadd_front(&new, test);
last = ft_lstlast(new);
//printf("\nlongueur de la liste : %d", ft_lstsize(test));
printf("\nle dernier element de la liste : %s", (char *) last->content);
} */