diff options
Diffstat (limited to 'libft/ft_strrchr.c')
-rw-r--r-- | libft/ft_strrchr.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libft/ft_strrchr.c b/libft/ft_strrchr.c new file mode 100644 index 0000000..78bad68 --- /dev/null +++ b/libft/ft_strrchr.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strrchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kdx <kdx @student.42angouleme.fr +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/09/27 23:37:56 by kdx #+# #+# */ +/* Updated: 2022/09/27 23:43:59 by kdx ### ########.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); +} |