Count Tokens

This snippet in C counts tokens that will be found with strtok(3).

int tokcnt(const char *s, const char *delim)
{
        int n = 0;

        while (*s)
                if (strchr(delim, *s++) == NULL) {
                        ++n;
                        while (strchr(delim, *s) == NULL)
                                ++s;
                }
        return n;
}

Get it!