strcmp.c 439 B

1234567891011121314151617181920
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Id$ */
  6. #include <string.h>
  7. int
  8. strcmp(register const char *s1, register const char *s2)
  9. {
  10. while (*s1 == *s2++) {
  11. if (*s1++ == '\0') {
  12. return 0;
  13. }
  14. }
  15. if (*s1 == '\0') return -1;
  16. if (*--s2 == '\0') return 1;
  17. return (unsigned char) *s1 - (unsigned char) *s2;
  18. }