Quote Originally Posted by anon View Post
Perhaps you could initialize the table in a way and reference it through a (static) pointer that would allow you to use negative indices (if the signedness of the char type is implementation defined as I suspect you might set it all up at runtime - or may-be at compile time through some tricks).

I also wonder why you are determining the case sensitivity within the function. There is already strcmp which should be good for case sensitive comparisons, so you'd only need to implement the case insensitive version. And if you want a function that makes this choice through a third parameter, that would only call either strcmp or your version.

Also, do you need those ints. If you figure out the correct indexing, it needn't be more complex than
Code:
while (*s1 && *s2 && table[*s1] == table[*s2]) {
    ++s1;
    ++s2;
}
return something
I would also suggest fixing the function's prototype. It doesn't change the strings, so they should be const char*'s.
Yes, it's now only for testing. Later on i will only have case insensitive version. But thanks for other tips...