// todo - write strlen // strcmp function int strcmp(char *s1, char *s2) { if (s1 == NULL || s2 == NULL) return 0; int diff, i; for(i=0; s1[i] != '\0' && s2[i] != '\0'; i++) { diff = s1[i] - s2[i]; if (diff != 0) return diff; } // if here, then s1 and s2 were equal up to the end of one of them if (s1[i] == '\0' && s2[i] == '\0') return 0; if (s1[i] == '\0') return -1; else return 1; }