diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-29 19:50:20 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-29 19:50:20 +0200 |
commit | 9a915b797a80c2a776027b1fcc37f1e7b8ab1b24 (patch) | |
tree | 99a0fdb289fa4ec03e8b5cc179d6c6d073f6a84a /libft/src/ft_strnstr.c | |
parent | Fix (diff) | |
download | 42-minishell-9a915b797a80c2a776027b1fcc37f1e7b8ab1b24.tar.gz 42-minishell-9a915b797a80c2a776027b1fcc37f1e7b8ab1b24.tar.bz2 42-minishell-9a915b797a80c2a776027b1fcc37f1e7b8ab1b24.tar.xz 42-minishell-9a915b797a80c2a776027b1fcc37f1e7b8ab1b24.tar.zst 42-minishell-9a915b797a80c2a776027b1fcc37f1e7b8ab1b24.zip |
Update
Diffstat (limited to 'libft/src/ft_strnstr.c')
-rw-r--r-- | libft/src/ft_strnstr.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/libft/src/ft_strnstr.c b/libft/src/ft_strnstr.c index 58e1d0e..615320e 100644 --- a/libft/src/ft_strnstr.c +++ b/libft/src/ft_strnstr.c @@ -14,8 +14,7 @@ #include <stddef.h> #include <inttypes.h> -char - *ft_strnstr(const char *haystack, const char *needle, size_t len) +char *ft_strnstr(const char *haystack, const char *needle, size_t len) { unsigned long i; unsigned long j; @@ -25,14 +24,14 @@ char hay_ptr = (char*)haystack; nee_ptr = (char*)needle; i = 0; - if (!nee_ptr[0]) + if (nee_ptr[0] == '\0') return (hay_ptr); while (hay_ptr[i] && i < len) { j = 0; while (nee_ptr[j] == hay_ptr[i + j] && (i + j) < len) { - if (!nee_ptr[j + 1]) + if (nee_ptr[j + 1] == '\0') return (hay_ptr + i); j++; } |