strncasecmp.c - randomcrap - random crap programs of varying quality
HTML git clone git://git.codemadness.org/randomcrap
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
strncasecmp.c (322B)
---
1 #include <ctype.h>
2 #include <stdio.h>
3
4 int
5 strncasecmp(const char *s1, const char *s2, size_t n)
6 {
7 if (!n--)
8 return 0;
9
10 for (; *s1 && *s2 && n && (*s1 == *s2 ||
11 tolower((unsigned char)*s1) == tolower((unsigned char)*s2)); s1++, s2++, n--)
12 ;
13 return tolower((unsigned char)*s1) - tolower((unsigned char)*s2);
14 }