1 #include <lib9.h> 2 3 int 4 strncmp(char *s1, char *s2, long n) 5 { 6 unsigned c1, c2; 7 8 while(n > 0) { 9 c1 = *s1++; 10 c2 = *s2++; 11 n--; 12 if(c1 != c2) { 13 if(c1 > c2) 14 return 1; 15 return -1; 16 } 17 if(c1 == 0) 18 break; 19 } 20 return 0; 21 } 22