Home >Backend Development >C++ >In C/C++, the wcspbrk() function is translated as follows:
The wcspbrk() function is a built-in function of C or C. It searches one wide string for a set of wide characters present in another wide string. This function is located in the cwhar header file.
This function accepts two parameters. The first parameter is the target string and the second parameter is the source string. As the target string we have to pass a null terminated wide string to search for. As the source string, we must pass a null-terminated wide string containing the characters to be searched for.
This function returns two values. If one or more wide characters are present in the destination string or source string, this function returns a pointer to the first wide character in the destination string and source string. If there are no wide characters in the destination or source string, a null pointer is returned.
<span class="com">#include</span><span class="pln"> </span><span class="str"><cwchar></span> <span class="com">#include</span><span class="pln"> </span><span class="str"><iostream></span> <span class="kwd">using</span><span class="pln"> </span><span class="kwd">namespace</span><span class="pln"> std</span><span class="pun">;</span> <span class="pln">main </span><span class="pun">() {</span> <span class="typ"> wchar_t</span><span class="pln"> wcs</span><span class="pun">[]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> L</span><span class="str">"Hello World. This is C++ PROGRAM."</span><span class="pun">;</span> <span class="typ"> wchar_t</span><span class="pln"> key</span><span class="pun">[]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> L</span><span class="str">"aeiouAEIOU"</span><span class="pun">;</span> <span class="typ"> wchar_t</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> pwc</span><span class="pun">;</span> <span class="pln"> wcout </span><span class="pun"><<</span><span class="pln"> L</span><span class="str">"Vowels in '"</span><span class="pun"><<</span><span class="pln"> wcs </span><span class="pun"><<</span><span class="pln"> </span><span class="str">"': "</span><span class="pun">;</span> <span class="pln"> pwc </span><span class="pun">=</span><span class="pln"> wcspbrk </span><span class="pun">(</span><span class="pln">wcs</span><span class="pun">,</span><span class="pln"> key</span><span class="pun">);</span> <span class="kwd"> while</span><span class="pln"> </span><span class="pun">(</span><span class="pln">pwc </span><span class="pun">!=</span><span class="pln"> NULL</span><span class="pun">) {</span> <span class="pln"> wcout </span><span class="pun"><<</span><span class="pln"> </span><span class="pun">*</span><span class="pln">pwc </span><span class="pun"><<</span><span class="pln"> L</span><span class="str">" "</span><span class="pun">;</span> <span class="pln"> pwc </span><span class="pun">=</span><span class="pln"> wcspbrk </span><span class="pun">(</span><span class="pln">pwc</span><span class="pun">+</span><span class="lit">1</span><span class="pun">,</span><span class="pln">key</span><span class="pun">);</span> <span class="pun"> }</span> <span class="pln"> wcout </span><span class="pun"><<</span><span class="pln"> L</span><span class="str">"\n"</span><span class="pun">;</span> <span class="pun">}</span>
Vowels in 'Hello World. This is C++ PROGRAM.': e o o i i O A
The above is the detailed content of In C/C++, the wcspbrk() function is translated as follows:. For more information, please follow other related articles on the PHP Chinese website!