-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstsize.c
42 lines (39 loc) · 1.38 KB
/
ft_lstsize.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gudaniel <gudaniel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/25 13:45:20 by gudaniel #+# #+# */
/* Updated: 2024/04/25 17:36:11 by gudaniel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int i;
i = 0;
while (lst)
{
lst = lst->next;
i++;
}
return (i);
}
/* int main(void)
{
t_list *lst;
lst = (t_list *)malloc(sizeof(t_list));
lst->content = ft_strdup("hello ");
lst->next = ft_lstnew(ft_strdup("world"));
lst->next->next = ft_lstnew(ft_strdup(" mannn"));
int i = ft_lstsize(lst);
printf("%d\n", i);
while (lst)
{
printf("%s", (char *)lst->content);
lst = lst->next;
}
return (0);
} */