-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstlast.c
44 lines (41 loc) · 1.37 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
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstlast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thuy-ngu <thuy-ngu@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/02 21:22:25 by thuy-ngu #+# #+# */
/* Updated: 2023/10/21 03:07:34 by thuy-ngu ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstlast(t_list *lst)
{
if (!lst)
return (NULL);
while (lst->next)
{
lst = lst->next;
}
return (lst);
}
/*int main()
{
t_list *list;
char *s1 = "content 1";
char *s2 = "content 2";
char *s3 = "content 3";
t_list* n1 = ft_lstnew(s1);
t_list* n2 = ft_lstnew(s2);
t_list* n3 = ft_lstnew(s3);
list = n1;
n1->next = n2;
n2->next = n3;
n3->next = NULL;
t_list *last = ft_lstlast(list);
printf("%s\n", (char *)last->content);
free(n1);
free(n2);
free(n3);
}*/