-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstsize.c
55 lines (51 loc) · 1.54 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
43
44
45
46
47
48
49
50
51
52
53
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sde-silv <sde-silv@student.42berlin.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/04 13:58:55 by sde-silv #+# #+# */
/* Updated: 2023/10/04 13:59:06 by sde-silv ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int size;
t_list *current;
size = 0;
current = lst;
while (current != NULL)
{
size ++;
current = current->next;
}
return (size);
}
/*
int main(void)
{
t_list *head;
t_list *current;
t_list **lst;
t_list *new;
int size;
head = ft_lstnew((void *)10);
head->next = ft_lstnew((void *)20);
new = ft_lstnew((void *)30);
*lst = head;
new = ft_lstnew((void *)30);
ft_lstadd_front(lst, new);
current = *lst;
size = ft_lstsize(*lst);
printf("size: %d\n", size);
while (size > 0)
{
printf("%zu\n", (size_t)current->content);
current = current->next;
size --;
}
return (0);
}
*/