首頁 > 後端開發 > 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學習者快速成長!