📅  最后修改于: 2020-09-25 10:03:59             🧑  作者: Mango
wcsstr() 函数在
const wchar_t* wcsstr( const wchar_t* dest, const wchar_t* src );
wchar_t* wcsstr( wchar_t* dest, const wchar_t* src )
wcsstr() 函数采用两个参数: dest
和src
。它在dest
指向的宽字符串搜索src
的第一个匹配项。终止的null宽字符将被忽略。
#include
#include
#include
using namespace std;
int main()
{
setlocale(LC_ALL, "en_US.utf8");
wchar_t src[] = L"ĸņoŵ";
wchar_t dest[] = L"You must ĸņoŵ these facts";
wchar_t *p = wcsstr(dest, src);
if (p)
wcout << L"\"" << src << L"\" is present in \"" << dest << L"\" at position " << (p-dest);
else
wcout << L"\"" << src << L"\" is not present in \"" << dest << L"\"";
return 0;
}
运行该程序时,输出为:
"ĸņoŵ" is present in "You must ĸņoŵ these facts" at position 9