strcspn

Searches for a character string comprising only characters not included in a specified character set

#include <strings.h>
size_t strcspn (
        const char *s1,
        const char *s2
)

Arguments

s1 Pointer to target character string to be searched
s2 Pointer to string which contains the character set

Return Value

The length of the segment within the string pointed to by s1 that does not contain any characters from the string pointed to by s2 is returned.

Explanation

The character string starting from the beginning of the string pointed to by s1 that does not contain any characters that are contained in the character set pointed to by s2 is located and its length is returned.