2021-05-23 17:04:08 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int strncmp(const char *s1, const char *s2, size_t n)
|
|
|
|
{
|
|
|
|
if (n == 0)
|
|
|
|
return (0);
|
|
|
|
size_t i = -1;
|
|
|
|
while (++i < n - 1 && s1[i] != '\0' && s2[i] != '\0'
|
|
|
|
&& s1[i] == s2[i]) ;
|
2022-11-24 13:30:46 +01:00
|
|
|
return ((unsigned char) s1[i] - (unsigned char) s2[i]);
|
2021-05-23 17:04:08 +02:00
|
|
|
}
|