minishell/libft/libft/ft_lstsize_bonus.c
2025-02-12 15:12:42 +01:00

29 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/21 13:54:34 by jguelen #+# #+# */
/* Updated: 2024/10/23 16:33:32 by jguelen ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*Presumes the linked list not to be circular*/
int ft_lstsize(t_list *lst)
{
int len;
len = 1;
if (lst == NULL)
return (0);
while (lst->next)
{
len++;
lst = lst->next;
}
return (len);
}