2.1.2.60 strspn


Description

Find a prefix substring in a string consisting entirely of characters in a specified character set.

Syntax

size_t strspn( LPCSTR lpcszString, LPCSTR lpcszCharSet )

Parameters

lpcszString
[input] String to search through
lpcszCharSet
[input] String containing specified character set

Return

Returns the index (based from 0) of the first character in a string that is not in a specified character set. All characters before returned index are in the character set.

Examples

EX1

void strspn_ex1()
{
    char str1[] = "Mississippi";

    out_int("", strspn( str1, "Mis" )); // The output is 8
    out_int("", strspn( str1, "Misp" )); //The output is 11
    out_int("", strspn( str1, "mIS" )); //The output is 0
}

Remark

Find a prefix substring in a string consisting entirely of characters in a specified character set.

See Also

strcspn

Header to Include

origin.h

Reference