strcasestr.c - randomcrap - random crap programs of varying quality
(HTM) git clone git://git.codemadness.org/randomcrap
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
strcasestr.c (322B)
---
1 #include <ctype.h>
2 #include <stdio.h>
3
4 char *
5 strcasestr(const char *h, const char *n)
6 {
7 size_t i;
8
9 if (!n[0])
10 return (char *)h;
11
12 for (; *h; ++h) {
13 for (i = 0; n[i] && tolower((unsigned char)n[i]) ==
14 tolower((unsigned char)h[i]); ++i)
15 ;
16 if (n[i] == '\0')
17 return (char *)h;
18 }
19
20 return NULL;
21 }