-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstlast.c
More file actions
38 lines (36 loc) · 1.29 KB
/
ft_lstlast.c
File metadata and controls
38 lines (36 loc) · 1.29 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstlast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gudaniel <gudaniel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/25 13:53:19 by gudaniel #+# #+# */
/* Updated: 2024/04/25 17:36:18 by gudaniel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstlast(t_list *lst)
{
while (lst)
{
if (!lst->next)
return (lst);
lst = lst->next;
}
return (lst);
}
/* int main(int ac, char **av)
{
(void)ac;
int i = 2;
t_list *root = ft_lstnew(av[1]);
while (av[i])
{
root->next = ft_lstnew(av[i]);
i++;
}
t_list *last = ft_lstlast(root);
printf("%s\n", (char *)last->content);
return (0);
} */