add: strncmp
This commit is contained in:
parent
53faf0936e
commit
37c15e5740
12
src/string/strncmp.c
Normal file
12
src/string/strncmp.c
Normal 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];
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user