std::wcsstr
來自 cppreference.com
在標頭檔案 <cwchar> 中定義 |
||
const wchar_t* wcsstr( const wchar_t* dest, const wchar_t* src ); |
||
wchar_t* wcsstr( wchar_t* dest, const wchar_t* src ); |
||
在 dest 指向的寬字串中查詢寬字串 src 的第一次出現。不比較終止空字元。
目錄 |
[編輯] 引數
dest | - | 指向要檢查的空終止寬字串的指標 |
src | - | 指向要搜尋的空終止寬字串的指標 |
[編輯] 返回值
指向在 dest 中找到的子字串的第一個字元的指標,如果未找到此類子字串,則返回空指標。如果 src 指向空字串,則返回 dest。
[編輯] 示例
執行此程式碼
#include <clocale> #include <cwchar> #include <iostream> int main() { wchar_t const* origin = L"アルファ, ベータ, ガンマ, アルファ, ベータ, ガンマ."; wchar_t const* target = L"ベータ"; wchar_t const* result = origin; std::setlocale(LC_ALL, "en_US.utf8"); std::wcout << L"Substring to find: \"" << target << L"\"\n" << L"String to search: \"" << origin << L"\"\n\n"; for (; (result = std::wcsstr(result, target)) != nullptr; ++result) std::wcout << L"Found: \"" << result << L"\"\n"; }
可能的輸出
Substring to find: "ベータ" String to search: "アルファ, ベータ, ガンマ, アルファ, ベータ, ガンマ." Found: "ベータ, ガンマ, アルファ, ベータ, ガンマ." Found: "ベータ, ガンマ."
[編輯] 參閱
查詢給定子字串的第一次出現 ( std::basic_string<CharT,Traits,Allocator> 的公共成員函式) | |
查詢字元子字串的第一次出現 (函式) | |
在寬字串中查詢寬字元的首次出現 (函式) | |
在寬字串中查詢寬字元的最後一次出現 (函式) | |
C 文件 for wcsstr
|