最終更新日時:
が更新

履歴 編集

function
<cwchar>

std::wcsstr

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;
}

出力

6

バージョン

言語

  • C++98

関連項目

参照