wcsspn() — Find Offset of First Non-matching Wide Character
Format
#include <wchar.h>
size_t wcsspn(const wchar_t *string1, const wchar_t *string2);
Language Level
ANSI
Threadsafe
Yes
Wide Character Function
See Wide Characters for more information.
Description
The wcsspn()
function
computes the number of wide characters in the initial segment of the
string pointed to by string1, which consists
entirely of wide characters from the string pointed to by string2.
Return Value
The wcsspn()
function
returns the number of wide characters in the segment.
Example
This example finds the first occurrence
in the array string of a wide character that is not an a, b,
or c. Because the string in this example is cabbage,
the
wcsspn()
function
returns 5, the index of the segment of cabbage before
a character that is not an a, b, or c.
#include <stdio.h>
#include <wchar.h>
int main(void)
{
wchar_t * string = L"cabbage";
wchar_t * source = L"abc";
int index;
index = wcsspn( string, L"abc" );
printf( "The first %d characters of \"%ls\" are found in \"%ls\"\n",
index, string, source );
}
/**************** Output should be similar to: ******************
The first 5 characters of "cabbage" are found in "abc"
*/
Related Information
- strchr() — Search for Character
- strcspn() — Find Offset of First Character Match
- strpbrk() — Find Characters in String
- strrchr() — Locate Last Occurrence of Character in String
- strspn() — Find Offset of First Non-matching Character
- wcscat() — Concatenate Wide-Character Strings
- wcschr() — Search for Wide Character
- wcscmp() — Compare Wide-Character Strings
- wcscspn() — Find Offset of First Wide-Character Match
- wcsncmp() — Compare Wide-Character Strings
- wcspbrk() — Locate Wide Characters in String
- wcsrchr() — Locate Last Occurrence of Wide Character in String
- wcsspn() — Find Offset of First Non-matching Wide Character
- wcswcs() — Locate Wide-Character Substring
- <wchar.h>