I am currently writing a C program that requires frequent comparisons of string lengths so I wrote the following helper function:
int strlonger(char *s1, cha
Alex Lockwood's answer is the best solution (compact, clear semantics, etc).
Sometimes it does make sense to explicitly convert to a signed form of size_t: ptrdiff_t, e.g.
return ptrdiff_t(strlen(s1)) - ptrdiff_t(strlen(s2)) > 0;
If you do this, you'll want to be certain that the size_t value fits in a ptrdiff_t (which has one fewer mantissa bits).