Archived
1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
so_long/libft/ft_strrchr.c

34 lines
1.2 KiB
C
Raw Normal View History

2024-01-13 19:13:17 +01:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 14:44:26 by adjoly #+# #+# */
/* Updated: 2023/11/08 15:21:28 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
size_t i;
size_t len_s;
len_s = ft_strlen(s);
i = len_s;
if (c == 0)
return (&((char *)s)[len_s]);
while (i > 0)
{
if (s[i] == (char)c)
return (&((char *)s)[i]);
i--;
}
if (s[0] == (char)c)
return (&((char *)s)[0]);
return (NULL);
}