Implement strcmp().
int my_strcmp(const char *a, const char *b)
{
while (*a && *a == *b) { a++; b++; }
return (unsigned char)*a - (unsigned char)*b;
}
Points: the result is negative, zero or positive, not necessarily −1/0/1. Compare as unsigned char, as the standard requires, so bytes above 127 order correctly. The loop stops at the first difference or when a ends (if b ended first, *b is 0 and differs). strncmp adds a count limit.