summaryrefslogtreecommitdiff
path: root/ft_strnstr.c
diff options
context:
space:
mode:
authorDominik Kaiser2024-03-10 19:10:22 +0100
committerDominik Kaiser2024-03-10 19:10:22 +0100
commitbd89cee6a4fa8ca6c212632a48d1647e44a9e46c (patch)
tree0a44e91843491aa31645bcdc160754711b4eeff0 /ft_strnstr.c
parentb356e8552cad748418163bf3ad1da95e88937a38 (diff)
downloadlibft-bd89cee6a4fa8ca6c212632a48d1647e44a9e46c.tar.gz
libft-bd89cee6a4fa8ca6c212632a48d1647e44a9e46c.zip
Bonus
Diffstat (limited to 'ft_strnstr.c')
-rw-r--r--ft_strnstr.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/ft_strnstr.c b/ft_strnstr.c
index 54868d4..453af18 100644
--- a/ft_strnstr.c
+++ b/ft_strnstr.c
@@ -6,7 +6,7 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/06 16:07:54 by dkaiser #+# #+# */
-/* Updated: 2024/03/10 13:16:58 by dkaiser ### ########.fr */
+/* Updated: 2024/03/10 14:42:21 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,7 +17,7 @@ char *ft_strnstr(const char *haystack, const char *needle, size_t len)
size_t i;
size_t k;
- if (len < 0 || (!haystack[0] && needle[0]))
+ if (len < 0 || (!*haystack && *needle))
return (0);
i = 0;
if (*needle == '\0' || needle == haystack)
@@ -26,9 +26,7 @@ char *ft_strnstr(const char *haystack, const char *needle, size_t len)
{
k = 0;
while (haystack[i + k] && haystack[i + k] == needle[k] && i + k < len)
- {
k++;
- }
if (!needle[k])
return ((char *)haystack + i);
i++;