Repository navigation
Expand file tree
/
Copy pathft_lstsize.c
More file actions
61 lines (51 loc) · 1.48 KB
/
Copy pathft_lstsize.c
File metadata and controls
61 lines (51 loc) · 1.48 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
49
50
51
52
53
54
55
56
57
58
59
60
61
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: asalniko <asalniko@student.42berlin.d +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/17 16:19:10 by asalniko #+# #+# */
/* Updated: 2025/02/17 16:19:22 by asalniko ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int i;
t_list *temp;
i = 0;
temp = lst;
while (temp)
{
i++;
temp = temp->next;
}
return (i);
}
/*
#include <stdio.h>
t_list *ft_lstnew(void *content)
{
t_list *newnode;
newnode = (t_list *)malloc(sizeof(t_list));
if (!newnode)
return (NULL);
newnode->content = content;
newnode->next = NULL;
return (newnode);
}
int main(void)
{
t_list *a = ft_lstnew("one");
t_list *b = ft_lstnew("two");
t_list *c = ft_lstnew("three");
a->next = b;
b->next = c;
printf("List size: %d\n", ft_lstsize(a));
free(a);
free(b);
free(c);
return (0);
}
*/