From 8adeef1b50a3a819cf6525af94f1fbce62465a7e Mon Sep 17 00:00:00 2001 From: Cabergs Charles Date: Mon, 7 Oct 2019 16:33:51 +0200 Subject: Added calloc and strlcpy, rename out of date --- ft_strnstr.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'ft_strnstr.c') 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 +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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 #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); -- cgit