aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_strncmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_strncmp.c')
-rw-r--r--src/ft_strncmp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ft_strncmp.c b/src/ft_strncmp.c
new file mode 100644
index 0000000..2fa1099
--- /dev/null
+++ b/src/ft_strncmp.c
@@ -0,0 +1,16 @@
+#include "libft.h"
+
+int
+ft_strncmp (const char *s1, const char *s2, size_t n)
+{
+ while (n--)
+ {
+ if ((unsigned char)*s1 != (unsigned char)*s2)
+ return ((unsigned char)*s1 - (unsigned char)*s2);
+ if (*s1 == '\0')
+ return (0);
+ s1++;
+ s2++;
+ }
+ return (0);
+}