-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstsize.c
More file actions
48 lines (45 loc) · 1.43 KB
/
ft_lstsize.c
File metadata and controls
48 lines (45 loc) · 1.43 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: sudaniel <sudaniel@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/12 07:31:59 by sudaniel #+# #+# */
/* Updated: 2024/10/12 07:46:05 by sudaniel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int count;
count = 0;
while (lst)
{
count++;
lst = lst->next;
}
return (count);
}
/*
int main(void)
{
int value = 42, value1 = 124, count = 5;
t_list *list = ft_lstnew(&value);
t_list *new_node = ft_lstnew(&value1);
ft_lstadd_front(&list, new_node);
while (count--)
{
new_node = ft_lstnew(&count);
ft_lstadd_front(&list, new_node);
}
printf("There are %d numbers of nodes in the list.\n", ft_lstsize(list));
while (list)
{
t_list *temp = list;
list = list->next;
free(temp);
}
return (0);
}
*/