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.
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 :
Occurrence of a character in -> geeksforgeeks012345 is at position : 13
Program 2 :
Length of the string -> GFG is : 3
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Difference between user defined function and library function in C/C++
- Function Overloading vs Function Overriding in C++
- How to call some function before main() function in C++?
- How to call function within function in C or C++
- Difference between Virtual function and Pure virtual function in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- arc function in C
- fma() function in C++
- div() function in C++
- exp() function C++
- log() function in C++
- map key_comp() function in C++ STL
- Inline function in C
- max() function for valarray in C++
- map rbegin() function in C++ STL
- map rend() function in C++ STL
- regex_iterator() function in C++ STL
- valarray cos() function in C++
- valarray tan() function in C++
- valarray pow() function in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ManasChhabra2