wcscspn() function in C/C++ Last Updated : 16 Oct, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The wcscspn() function in C/C++ searches the first occurrence of a wide character of string_2 in the given wide string_1. It returns the number of wide characters before the first occurrence of that wide character . The search includes the terminating null wide characters. Therefore, the function will return the length of string_1 if none of the characters of string_2 are found in string_1. Syntax: size_t wcscspn( const wchar_t* string_1, const wchar_t* string_2 ) Parameter : The function accepts two mandatory parameters which are described below: string_1 : specifies the string to be searched string_2 : specifies the string containing the characters to be searched Return value: The function returns two value as below: It returns the number of wide characters in string_2 before the first occurrence of any wide characters present in string_1. length of string_1 is returned if none of the wide characters in string_2 are found in string_1 Below programs illustrate the above function: Program 1 : CPP // C++ program to illustrate // wcscspn() function #include <bits/stdc++.h> using namespace std; int main() { // string to be scanned wchar_t string_1[] = L"geeksforgeeks012345"; // string containing the character to match wchar_t string_2[] = L"0123456789"; // scanning the strings int last = wcscspn(string_1, string_2); // print the position of a matched character if (last > wcslen(string_1)) wcout << string_1 << L" Didn't match any character"; else wcout << L"Occurrence of a character in -> \n" << string_1 << " is at position : " << last; return 0; } Output: Occurrence of a character in -> geeksforgeeks012345 is at position : 13 Program 2 : CPP // C++ program to illustrate // wcscspn() function #include <bits/stdc++.h> using namespace std; int main() { // string to be scanned wchar_t string_1[] = L"GFG"; // string containing the character to match wchar_t string_2[] = L"909090909"; // scanning the strings int last = wcscspn(string_1, string_2); // print the position of a matched character if (last > wcslen(string_1)) wcout << string_1 << L" does not contain numbers"; else wcout << L"Length of the string -> " << string_1 << " is : " << last; return 0; } Output: Length of the string -> GFG is : 3 Comment More infoAdvertise with us Next Article wcscspn() function in C/C++ A AmanSrivastava1 Follow Improve Article Tags : C++ CPP-Functions C-Library Practice Tags : CPP Similar Reads strcspn() function in C/C++ The strcspn() function in C/C++ takes two string as input, string_1 and string_2 as it's argument and searches string_1 by traversing for any characters that is present in string_2 . The function will return the length of string_1 if none of the characters of string_2 are found in string_1 . This fu 2 min read wcsncmp() function in C/C++ The wcsncmp() function in C/C++ compare characters of two wide strings. The comparison is done lexicographically. This function takes three arguments lhs, rhs and count. It compares the contents of lhs and rhs lexicographically upto a maximum of count wide characters. Note: The behaviour of wcsncmp( 3 min read wcspbrk() function in C/C++ The wcspbrk() is a built-in function in C/C++ which searches for a set of wide characters present in a wide string in another wide string. It is defined within the cwchar header file of C++. Syntax: wcspbrk(dest, src) Parameters: The function has two parameters as shown below. dest: It specifies the 2 min read wcsncat() function in C/C++ The wcsncat() function appends the characters of the source to the destination, including a terminating null wide character. If the length of the string in source is less than num. Then only the content up to the terminating null wide character is copied. Syntax: wchar_t* wcsncat (wchar_t* destinati 2 min read wcsrchr() function in C/C++ The wcsrchr() function is a builtin function in C/C++ which searches for the last occurrence of a wide character in a wide string. It is defined within the cwchar header file in C++. Syntax: wcsrchr(str, ch) Parameters: The function accepts two parameters which are described below. str: It specifies 2 min read Like