-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstsize_bonus.c
More file actions
47 lines (41 loc) · 1.32 KB
/
ft_lstsize_bonus.c
File metadata and controls
47 lines (41 loc) · 1.32 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mjusta <mjusta@student.42prague.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/28 18:27:08 by mjusta #+# #+# */
/* Updated: 2025/05/28 19:02:08 by mjusta ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int count;
count = 0;
while (lst)
{
count++;
lst = lst->next;
}
return (count);
}
/*
#include <stdio.h>
int main(void)
{
t_list *a = ft_lstnew("first");
t_list *b = ft_lstnew("second");
t_list *c = ft_lstnew("third");
ft_lstadd_front(&a, b);
ft_lstadd_front(&b, c);
printf("%i items in the list", ft_lstsize(c));
t_list *tmp;
while (c)
{
tmp = c->next;
free(c);
c = tmp;
}
}*/