home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / lib / dlibssrc / strcmp.c < prev    next >
Encoding:
Text File  |  1987-06-14  |  406 b   |  18 lines

  1. int strcmp(str1, str2)
  2. register char *str1;
  3. register char *str2;
  4. /*
  5.  *    Lexicographically compare the two strings.  Return a value
  6.  *    indicating the relationship between the strings.  Possible
  7.  *    return values are:
  8.  *        negative    str1 < str2
  9.  *        0        str1 == str2
  10.  *        positive    str1 > str2
  11.  */
  12. {
  13.     for(; *str1 == *str2; ++str1, ++str2)
  14.         if(*str1 == '\0')
  15.             return(0);
  16.     return(*str1 - *str2);
  17. }
  18.