wcswcs() - ワイド文字ストリング内のワイド文字サブストリングの位置検出

標準

標準/拡張機能 C/C++ 依存項目

ISO C 改訂
XPG4
XPG4.2
C99
Single UNIX Specification、バージョン 3

両方  

形式

#include <wchar.h>

wchar_t *wcswcs(const wchar_t *string1, const wchar_t *string2);

機能説明

string2 が指すストリング内の (終了ワイド NULL 文字を除く) 一連のワイド文字の string1 が指すストリング内の最初のオカレンスの位置を指定します。

このワイド文字関数の動作は、現行ロケールの LC_CTYPE カテゴリーの影響を受けます。 カテゴリーを変更すると、未定義の結果が発生する可能性があります。

注: wcswcs() 関数は Single UNIX Specification、バージョン 3 のレガシー・オプション・グループ に既に移動されていて、将来のバージョンで廃止する可能性があります。移植性の観点からは、wcsstr() 関数 が推奨されます。

戻り値

正常に実行された場合、wcswcs() は、検出されたストリングを指すポインターを戻します。

string2 がゼロ長のストリングを指す場合には、wcswcs() は、string1 を戻します。

ストリングが見付からなかった場合は、wcswcs() は NULL を戻します。

CELEBW26
⁄* CELEBW26

   This example finds the first occurrence of the wide character string pr
   in buffer1, using wcswcs().

 *⁄
#include <stdio.h>
#include <wcstr.h>

#define SIZE 40

int main(void)
{
  wchar_t buffer1[SIZE] = L"computer program";
  wchar_t *ptr;
  wchar_t *wch = L"pr";

  ptr = wcswcs( buffer1, wch );
  printf( "The first occurrence of %ls in '%ls' is '%ls'¥n",
                          wch, buffer1, ptr );
}
出力:
The first occurrence of pr in 'computer program' is 'program'

関連情報