diff options
Diffstat (limited to 'libft/ft_strrchr.c')
-rw-r--r-- | libft/ft_strrchr.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libft/ft_strrchr.c b/libft/ft_strrchr.c new file mode 100644 index 0000000..df363a2 --- /dev/null +++ b/libft/ft_strrchr.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strrchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kdx <kdx @student.42angouleme.fr +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/09/27 23:37:56 by kdx #+# #+# */ +/* Updated: 2022/10/14 02:37:31 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) + { + i -= 1; + if (s[i] == c) + return ((char *)(s + i)); + } + return (NULL); +} |