42_libft/ft_strrchr.c
Camille Chauvet be438f7dec v2
2022-10-04 14:21:55 +02:00

28 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/27 08:25:33 by cchauvet #+# #+# */
/* Updated: 2022/09/28 17:26:42 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
size_t i;
i = ft_strlen((char *) s);
while (i > 0 || s[i] == c)
{
if (s[i] == c)
return ((char *) &s[i]);
i--;
}
return (NULL);
}