home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3065 / strcasecmp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-15  |  405 b   |  20 lines

  1. /*
  2.  *    strcasecmp(s,t): Just like strcmp(3) but ignores case.
  3.  *
  4.  *    Adapted from strcmp() in K&&R, page 102.
  5.  *
  6.  *    George Ferguson, ferguson@cs.rochester.edu, 12 Feb 1991.
  7.  */
  8.  
  9. int
  10. strcasecmp(s,t)
  11. char *s,*t;
  12. {
  13.     for ( ; *s == *t ||
  14.         (*s >= 'A' && *s <= 'Z' && *s-'A'+'a' == *t) ||
  15.         (*t >= 'A' && *t <= 'Z' && *t-'A'+'a' == *s) ; s++, t++)
  16.     if (*s == '\0')
  17.         return(0);
  18.     return(*s - *t);
  19. }
  20.