aboutsummaryrefslogtreecommitdiffstats
path: root/ft_strncmp.c
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-21 12:39:20 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-21 12:39:34 +0100
commitd699849b2360f90c61f645c5d4d4232cd3e1c962 (patch)
treec929ec20ca3b16fe3d34bd75e412ca49f7420125 /ft_strncmp.c
downloadLibft-d699849b2360f90c61f645c5d4d4232cd3e1c962.tar.gz
Libft-d699849b2360f90c61f645c5d4d4232cd3e1c962.zip
Initial commit: libft Part 1 with tests and documentation
Reimplements 24 libc functions with Doxygen-documented header and test suite comparing against libc.
Diffstat (limited to 'ft_strncmp.c')
-rw-r--r--ft_strncmp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ft_strncmp.c b/ft_strncmp.c
new file mode 100644
index 0000000..2fa1099
--- /dev/null
+++ b/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);
+}