diff --git a/Makefile b/Makefile index 1696cc5..b701610 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: adjoly +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/01 11:03:22 by adjoly #+# #+# # -# Updated: 2023/11/05 22:23:43 by adjoly ### ########.fr # +# Updated: 2023/11/06 11:12:48 by adjoly ### ########.fr # # # # **************************************************************************** # diff --git a/ft_memchr.c b/ft_memchr.c index abccd56..927d102 100644 --- a/ft_memchr.c +++ b/ft_memchr.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */ -/* Updated: 2023/11/05 14:54:57 by adjoly ### ########.fr */ +/* Updated: 2023/11/06 15:37:15 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,5 +14,13 @@ void *ft_memchr(const void *s, int c, size_t n) { - + int i; + + i = 0; + while (i < n && ((unsigned char *)s)[i] && ((char *)s) != c) + { + s++; + i++; + } + return (NULL); } diff --git a/ft_strncmp.c b/ft_strncmp.c index 656bd37..71eaf9b 100644 --- a/ft_strncmp.c +++ b/ft_strncmp.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/05 10:40:45 by adjoly #+# #+# */ -/* Updated: 2023/11/05 11:02:33 by adjoly ### ########.fr */ +/* Updated: 2023/11/06 14:53:38 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,9 @@ int ft_strncmp(const char *s1, const char *s2, size_t n) size_t i; i = 0; - while (s1[i] && s2[i] && i < n && s1[i] != s2[i]) + if (n == 0) + return (0); + while (s1[i] == s2[i] && s1[i] && i < n - 1) i++; - return (s1[i] - s2[i]); + return ((unsigned char)s1[i] - (unsigned char)s2[i]); } diff --git a/libft.h b/libft.h index eef2e41..d402f9a 100644 --- a/libft.h +++ b/libft.h @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/01 10:06:03 by adjoly #+# #+# */ -/* Updated: 2023/11/05 21:34:36 by adjoly ### ########.fr */ +/* Updated: 2023/11/06 11:03:52 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,5 +44,6 @@ int ft_isprint(int c); void *ft_memchr(const void *s, int c, size_t n); char *ft_itoa(int n); void *ft_memmove(void *dest, const void *src, size_t n); +void *ft_memchr(const void *s, int c, size_t n); #endif \ No newline at end of file diff --git a/libft.so b/libft.so index 8fde708..1431981 100755 Binary files a/libft.so and b/libft.so differ