-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstsize.c
46 lines (37 loc) · 1.42 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tauer <tauer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 02:31:53 by tauer #+# #+# */
/* Updated: 2023/11/08 03:48:11 by tauer ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_lstsize(t_list *lst)
{
int size;
size = 0;
while (lst)
{
lst = lst->next;
size++;
}
return (size);
}
// int main(void)
// {
// // t_list *first = NULL;
// t_list *first = ft_lstnew("premier element");
// t_list *second = ft_lstnew("deuxieme element");
// t_list *third = ft_lstnew("troisieme element");
// // ft_lstadd_front(&first, second);
// first->next = second;
// second->next = third;
// third->next = NULL;
// int size_lst = ft_lstsize(first);
// printf("list size : %d\n", size_lst);
// return 0;
// }