add: strncmp

This commit is contained in:
starnakin 2024-09-06 23:08:56 +02:00
parent 53faf0936e
commit 37c15e5740

12
src/string/strncmp.c Normal file
View File

@ -0,0 +1,12 @@
#include <stddef.h>
int strncmp(const char *s1, const char *s2, size_t n)
{
size_t i = 0;
if (n == 0)
return 0;
while (s1[i] == s2[i] && i < (n - 1))
i++;
return s1[i] - s2[i];
}