aboutsummaryrefslogtreecommitdiff
path: root/src/string/strncmp.c
blob: 1a0264f5833097179f0b2dae2093f1506d527433 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#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;
}


#ifdef TEST
int
main(void) {
	return 0;
}
#endif