wcspbrk()函数是C或C++的内置函数。它在一个宽字符串中搜索另一个宽字符串中存在的一组宽字符。该函数位于cwhar头文件中。
该函数接受两个参数。第一个参数是目标字符串,第二个参数是源字符串。作为目标字符串,我们必须传递以空字符结尾的宽字符串进行搜索。作为源字符串,我们必须传递以空字符结尾的宽字符串,其中包含要搜索的字符。
该函数返回两个值。如果目标字符串或源字符串中存在一个或多个宽字符,该函数将返回指向目标字符串和源字符串中第一个宽字符的指针。如果目标字符串或源字符串中没有宽字符,则返回一个空指针。
<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
以上是在C/C++中,wcspbrk()函数的翻译如下:的详细内容。更多信息请关注PHP中文网其他相关文章!