Code Golf: strlen() implementation

Can you do a strlen implementation in just one line? Being that line under 80 characters (no cheating), and without the use of if-else statements, and/or while loops?

Yes, you can.

size_t strlen(const char *s) 
{
return((*s)?(strlen(++s)+1):(size_t)*s);
}

Don’t believe me? Try to compile it.

How does it work?

Recursion :)

First, let’s create our string, a simple “Hello world!”.
Next, by recursion, we will iterate the whole array (string), until we find the null character.
Now, we have our pointer (used as a counter) value saved in memory.
And viola! We exit from the recursion, and return the length of the string.

Procrastinating much?

Maybe…