aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_strnstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_strnstr.c')
-rw-r--r--src/ft_strnstr.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ft_strnstr.c b/src/ft_strnstr.c
new file mode 100644
index 0000000..23ac891
--- /dev/null
+++ b/src/ft_strnstr.c
@@ -0,0 +1,19 @@
+#include "libft.h"
+
+char *
+ft_strnstr (const char *big, const char *little, size_t len)
+{
+ size_t llen;
+
+ if (*little == '\0')
+ return ((char *)big);
+ llen = ft_strlen (little);
+ while (*big && len >= llen)
+ {
+ if (ft_memcmp (big, little, llen) == 0)
+ return ((char *)big);
+ big++;
+ len--;
+ }
+ return (NULL);
+}