/ libft / src / ft_lst / lst_at.c
lst_at.c
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   lst_at.c                                           :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: ll-hotel <ll-hotel@student.42lyon.fr>      +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2024/05/23 12:22:04 by ll-hotel          #+#    #+#             */
 9  /*   Updated: 2024/06/25 15:50:39 by ll-hotel         ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include "ft_lst.h"
14  
15  t_lst	*lst_at(t_lst_head *lst_head, unsigned long i)
16  {
17  	t_lst	*lst_elt;
18  
19  	lst_elt = lst_head->first;
20  	while (i-- > 0 && lst_elt)
21  		lst_elt = lst_elt->next;
22  	return (lst_elt);
23  }