42_libft/ft_strrchr.c
Camille Chauvet d4bc0e05a5 d
2022-10-04 22:04:23 +02:00

25 lines
1.0 KiB
C

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