summaryrefslogtreecommitdiffstats
path: root/libft
diff options
context:
space:
mode:
Diffstat (limited to 'libft')
-rw-r--r--libft/Makefile1
-rw-r--r--libft/include/libft.h1
-rw-r--r--libft/src/ft_strrnchr.c27
3 files changed, 29 insertions, 0 deletions
diff --git a/libft/Makefile b/libft/Makefile
index 66b8081..fb67ba7 100644
--- a/libft/Makefile
+++ b/libft/Makefile
@@ -37,6 +37,7 @@ SRCS_NAME += ft_tolower.c
SRCS_NAME += ft_toupper.c
SRCS_NAME += ft_strchr.c
SRCS_NAME += ft_strrchr.c
+SRCS_NAME += ft_strrnchr.c
SRCS_NAME += ft_strlchr.c
SRCS_NAME += ft_strncmp.c
SRCS_NAME += ft_strlcpy.c
diff --git a/libft/include/libft.h b/libft/include/libft.h
index 427f873..8ba0563 100644
--- a/libft/include/libft.h
+++ b/libft/include/libft.h
@@ -111,6 +111,7 @@ void *ft_nrealloc(void *ptr, size_t oldsize, size_t newsize);
char *ft_strcat(char *s1, const char *s2);
char *ft_strchr(const char *s, int c);
char *ft_strrchr(const char *s, int c);
+char *ft_strrnchr(const char *s, int c, size_t start);
char *ft_strnstr(const char *haystack, const char *needle,
size_t len);
char *ft_strdup(const char *s1);
diff --git a/libft/src/ft_strrnchr.c b/libft/src/ft_strrnchr.c
new file mode 100644
index 0000000..d6b8fdd
--- /dev/null
+++ b/libft/src/ft_strrnchr.c
@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strrnchr.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */
+/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+
+char *ft_strrnchr(const char *s, int c, size_t start)
+{
+ size_t i;
+
+ i = ft_strlen(s) - start;
+ while (s[i] != c)
+ {
+ if (i == 0)
+ return (NULL);
+ i--;
+ }
+ return ((char*)&s[i]);
+}