首页 > 后端开发 > C++ > 正文

在C/C++中,wcspbrk()函数的翻译如下:

WBOY
发布: 2023-08-27 12:41:06
转载
945 人浏览过

在C/C++中,wcspbrk()函数的翻译如下:

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 &#39;"</span><span class="pun"><<</span><span class="pln"> wcs </span><span class="pun"><<</span><span class="pln"> </span><span class="str">"&#39;: "</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 &#39;Hello World. This is C++ PROGRAM.&#39;: e o o i i O A
登录后复制

以上是在C/C++中,wcspbrk()函数的翻译如下:的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:tutorialspoint.com
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!