aboutsummaryrefslogtreecommitdiff
path: root/ft_strnstr.c
diff options
context:
space:
mode:
authorCabergs Charles <cacharle@w-r4-p5.s19.be>2019-10-07 16:33:51 +0200
committerCabergs Charles <cacharle@w-r4-p5.s19.be>2019-10-07 16:33:51 +0200
commit8adeef1b50a3a819cf6525af94f1fbce62465a7e (patch)
tree2076ffde529f8f5350515105645353f76ee1f5e9 /ft_strnstr.c
parentea6d7d262950a918f1888d7b8d9f6bceb1aaf12e (diff)
downloadlibft-8adeef1b50a3a819cf6525af94f1fbce62465a7e.tar.gz
libft-8adeef1b50a3a819cf6525af94f1fbce62465a7e.tar.bz2
libft-8adeef1b50a3a819cf6525af94f1fbce62465a7e.zip
Added calloc and strlcpy, rename out of date
Diffstat (limited to 'ft_strnstr.c')
-rw-r--r--ft_strnstr.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/ft_strnstr.c b/ft_strnstr.c
index 5f4bb91..d65a6f6 100644
--- a/ft_strnstr.c
+++ b/ft_strnstr.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/07 10:25:13 by cacharle #+# #+# */
-/* Updated: 2019/10/07 10:26:11 by cacharle ### ########.fr */
+/* Updated: 2019/10/07 12:40:59 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,27 +14,27 @@
#include <string.h>
#include "libft.h"
-char *ft_strnstr(const char *big, const char *little, size_t len)
+char *ft_strnstr(const char *haystack, const char *needle, size_t len)
{
size_t i;
size_t j;
- size_t little_len;
+ size_t needle_len;
- little_len = ft_strlen(little);
- if (little_len == 0 || len == 0)
- return ((char*)big);
+ needle_len = ft_strlen(needle);
+ if (needle_len == 0 || len == 0)
+ return ((char*)haystack);
i = 0;
- while (i < len && big[i])
+ while (i < len && haystack[i])
{
j = 0;
- while (i + j < len && little[j] && big[i + j])
+ while (i + j < len && needle[j] && haystack[i + j])
{
- if (little[j] != big[i + j])
+ if (needle[j] != haystack[i + j])
break ;
j++;
}
- if (j == little_len)
- return ((char*)big + i);
+ if (j == needle_len)
+ return ((char*)haystack + i);
i++;
}
return (NULL);