Syntax
#include <wchar.h> size_t wcsspn(const wchar_t *string1, const wchar_t *string2);Description
wcsspn scans string1 for the wide characters contained in string2. It stops when it encounters a character in string1 that is not in string2.
wcsspn returns the number of wide characters from string1 that are found in string2.
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, wcsspn 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); return 0; /**************************************************************************** The output should be: The first 5 characters of "cabbage" are found in "abc" ****************************************************************************/ }Related Information