std::wcsstr
来自cppreference.com
<tbody>
</tbody>
| 在标头 <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"要寻找的子串: \"" << target << L"\"\n"
<< L"要搜索的字符串: \"" << origin << L"\"\n\n";
for (; (result = std::wcsstr(result, target)) != nullptr; ++result)
std::wcout << L"找到: \"" << result << L"\"\n";
}
可能的输出:
要寻找的子串: "ベータ"
要搜索的字符串: "アルファ, ベータ, ガンマ, アルファ, ベータ, ガンマ."
找到: "ベータ, ガンマ, アルファ, ベータ, ガンマ."
找到: "ベータ, ガンマ."
参阅
| 寻找给定子串的首次出现 ( std::basic_string<CharT,Traits,Allocator> 的公开成员函数)
| |
| 寻找字符子串的首次出现 (函数) | |
| 寻找宽字符串中宽字符的首次出现 (函数) | |
| 在宽字符串中寻找宽字符的最后一次出现 (函数) | |
wcsstr 的 C 文档
| |