- cwchar[meta header]
- std[meta namespace]
- function[meta id-type]
namespace std {
const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2); // (1)
wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2); // (2)
}ワイド文字列から部分文字列を検索する。
s1が指す文字列の中で最初に現れるs2の並びを指すポインタを返す。見つからない場合はヌルポインタを返す。s2が空文字列である場合はs1を返す。
- この関数は、C++26からフリースタンディング処理系でも使用できる
#include <cwchar>
#include <iostream>
int main()
{
const wchar_t* s = L"hello world";
const wchar_t* p = std::wcsstr(s, L"wor");
std::wcout << (p - s) << std::endl;
}- std::wcsstr[color ff0000]
- std::wcout[link /reference/iostream/wcout.md]
6
- C++98
wcschrstd::strstr(): マルチバイト文字列版
- P2338R4 Freestanding Library: Character primitives and the C library
- C++26で、この関数がフリースタンディング処理系で使用可能になった