wcscspn() — Find Offset of First Wide-Character Match
Format
#include <wchar.h>
size_t wcscspn(const wchar_t *string1, const wchar_t *string2);
Language Level
XPG4
Threadsafe
Yes
Wide Character Function
See Wide Characters for more information.
Description
The wcscspn()
function
determines the number of wchar_t characters in the initial
segment of the string pointed to by string1 that
do not appear in the string pointed to by string2.
The wcscspn()
function
operates on null-ended wchar_t strings; string arguments
to this function should contain a wchar_t null character
marking the end of the string.
Return Value
The wcscspn()
function
returns the number of wchar_t characters in the segment.
Example
This example uses
wcscspn()
to
find the first occurrence of any of the characters a, x, l,
or e in string. #include <stdio.h>
#include <wchar.h>
#define SIZE 40
int main(void)
{
wchar_t string[SIZE] = L"This is the source string";
wchar_t * substring = L"axle";
printf( "The first %i characters in the string \"%ls\" are not in the "
"string \"%ls\" \n", wcscspn( string, substring),
string, substring );
}
/**************** Output should be similar to: ******************
The first 10 characters in the string "This is the source string" are not
in the string "axle"
*/
Related Information
- strcspn() — Find Offset of First Character Match
- strspn() — Find Offset of First Non-matching Character
- wcscat() — Concatenate Wide-Character Strings
- wcschr() — Search for Wide Character
- wcscmp() — Compare Wide-Character Strings
- wcscpy() — Copy Wide-Character Strings
- wcslen() — Calculate Length of Wide-Character String
- wcsspn() — Find Offset of First Non-matching Wide Character
- wcswcs() — Locate Wide-Character Substring
- <wchar.h>