aboutsummaryrefslogtreecommitdiff
path: root/src/str/ft_strncmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/str/ft_strncmp.c')
-rw-r--r--src/str/ft_strncmp.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/str/ft_strncmp.c b/src/str/ft_strncmp.c
index caa052b..a0371e4 100644
--- a/src/str/ft_strncmp.c
+++ b/src/str/ft_strncmp.c
@@ -11,16 +11,12 @@
/* ************************************************************************** */
#include "libft.h"
-#include "libft_types.h"
+#include "libft_str.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
- size_t i;
+ size_t len;
- if (n == 0)
- return (0);
- i = 0;
- while (i + 1 < n && s1[i] == s2[i] && s1[i])
- i++;
- return ((t_ftuchar)s1[i] - (t_ftuchar)s2[i]);
+ len = ft_strlen(s1);
+ return (ft_memcmp(s1, s2, n < len ? n : len + 1));
}