-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstsize.c
More file actions
48 lines (41 loc) · 1.41 KB
/
ft_lstsize.c
File metadata and controls
48 lines (41 loc) · 1.41 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
39
40
41
42
43
44
45
46
47
48
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sizerese <sizerese@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/05 23:49:52 by sizerese #+# #+# */
/* Updated: 2023/08/08 22:22:25 by sizerese ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int len;
t_list *ptr;
if (!lst)
return (0);
ptr = lst;
len = 0;
while (ptr != 0)
{
len++;
ptr = ptr->next;
}
return (len);
}
// int main(void)
// {
// t_list *head;
// t_list *node2;
// head = ft_lstnew(ft_strdup("hello"));
// head->next = NULL;
// node2 = ft_lstnew(ft_strdup("world"));
// node2->next = NULL;
// head->next = node2;
// node2 = ft_lstnew(ft_strdup("newworld"));
// node2->next = NULL;
// head->next->next = node2;
// printf("%d\n", ft_lstsize(head));
// }