strspn

Header: <string.h>

Returns the length of the maximum initial segment (span) of the null-terminated byte string pointed to by dest, that consists of only the characters found in the null-terminated byte string pointed to by src.

# Declarations

size_t strspn( const char* dest, const char* src );

# Parameters

# Return value

The length of the maximum initial segment that contains only characters from the null-terminated byte string pointed to by src.

# Example

#include <stdio.h>
#include <string.h>
 
int main(void)
{
    const char* string = "abcde312$#@";
    const char* low_alpha = "qwertyuiopasdfghjklzxcvbnm";
 
    size_t spnsz = strspn(string, low_alpha);
    printf("After skipping initial lowercase letters from '%s'\n"
           "The remainder is '%s'\n", string, string + spnsz);
}

# See also