skeletton untested project

This commit is contained in:
thrieg 2025-12-11 06:18:16 +01:00
commit 6fc620e8f4
187 changed files with 6584 additions and 0 deletions

44
libft/ft_lstlast_bonus.c Executable file
View file

@ -0,0 +1,44 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstlast_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/16 12:21:13 by thrieg #+# #+# */
/* Updated: 2025/02/16 19:04:00 by thrieg ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
//returns NULL if lst is NULL
t_list *ft_lstlast(t_list *lst)
{
if (!lst)
return (NULL);
while (lst->next)
lst = lst->next;
return (lst);
}
/*
* @return the element of `lst` at position `i`, NULL if doesn't exist.
* `ft_lstat(lst, 0)` returns `lst`.
*/
t_list *ft_lstat(t_list *lst, size_t i)
{
size_t j;
if (lst == NULL)
return (lst);
j = 0;
while (lst->next != NULL && j < i)
{
lst = lst->next;
j++;
}
if (j != i)
return (NULL);
return (lst);
}