Uhm.. way too complicated. Go for this one:
int strCmp(const char* s1, const char* s2)
{
while(*s1 && (*s1 == *s2))
{
s1++;
s2++;
}
return *(const unsigned char*)s1 - *(const unsigned char*)s2;
}
It returns <0, 0 or >0 as expected
You can't do it without pointers. In C, indexing an array is using pointers.
Maybe you want to avoid using the *
operator? :-)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…