strcmp.c 206 B

12345678910111213141516171819
  1. #include <lib9.h>
  2. int
  3. strcmp(char *s1, char *s2)
  4. {
  5. unsigned c1, c2;
  6. for(;;) {
  7. c1 = *s1++;
  8. c2 = *s2++;
  9. if(c1 != c2) {
  10. if(c1 > c2)
  11. return 1;
  12. return -1;
  13. }
  14. if(c1 == 0)
  15. return 0;
  16. }
  17. }