From 53faf0936ec4fd32dfa576f7f2e2e7c9705b9b1e Mon Sep 17 00:00:00 2001 From: starnakin Date: Fri, 6 Sep 2024 23:08:48 +0200 Subject: [PATCH] add: strcmp --- src/string/strcmp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/string/strcmp.c diff --git a/src/string/strcmp.c b/src/string/strcmp.c new file mode 100644 index 0000000..616ffd1 --- /dev/null +++ b/src/string/strcmp.c @@ -0,0 +1,10 @@ +#include + +int strcmp(const char *s1, const char *s2) +{ + size_t i = 0; + + while (s1[i] == s2[i] && s1[i] != '\0') + i++; + return s1[i] - s2[i]; +}