smol-gilbraltar/nolibc/strncmp.c
2024-12-20 23:45:12 +01:00

9 lines
220 B
C

#include <string.h>
int strncmp(const char *_l, const char *_r, size_t n)
{
const unsigned char *l=(void *)_l, *r=(void *)_r;
if (!n--) return 0;
for (; *l && *r && n && *l == *r ; l++, r++, n--);
return *l - *r;
}