Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 1.32 KB

File metadata and controls

58 lines (42 loc) · 1.32 KB

wcsstr

  • 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

関連項目

参照