function
<cwchar>
wcscspn
size_t wcscspn (const wchar_t* wcs1, const wchar_t* wcs2);
Get span until character in wide string
Scans wcs1 for the first occurrence of any of the wide characters that are part of wcs2, returning the number of wide characters of wcs1 read before this first occurrence.
The search includes the terminating null wide characters. Therefore, the function will return the length of wcs1 if none of the characters of wcs2 are found in wcs1.
This is the wide character equivalent of strcspn (<cstring>).
Parameters
- wcs1
- C wide string to be scanned.
- wcs2
- C wide string containing the characters to match.
Return value
The number of wide characters in the initial part of wcs1 that does not contain any of the characters that are part of wcs2.
This is the length of wcs1 if none of the wide characters in wcs2 are found in wcs1.
size_t is an unsigned integral type.
Example
1 2 3 4 5 6 7 8 9 10 11 12
|
/* wcscspn example */
#include <wchar.h>
int main ()
{
wchar_t wcs[] = L"fcba73";
wchar_t keys[] = L"1234567890";
int i;
i = wcscspn (wcs,keys);
wprintf (L"The first number in wcs is at position %d.\n",i+1);
return 0;
}
|
Output:
The first number in wcs is at position 5
|
See also
- strcspn
- Get span until character in string (function)
- wcspbrk
- Locate characters in wide string (function)
- wcsspn
- Get span of character set in wide string (function)
- wcsstr
- Locate substring of wide string (function)