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

フォーマット

#include <wchar.h>
wchar_t *wcswcs(const wchar_t *string1, const wchar_t *string2);

言語レベル

XPG4

スレッド・セーフ

はい

ワイド文字関数

詳細については、ワイド文字を参照してください。

説明

wcswcs() 関数は、string1 が指すワイド文字ストリング内の string2 が最初に現れる位置を見つけます。一致プロセスで、 wcswcs() 関数は、string2 を終了する wchar_t ヌル文字を 無視します。

戻り値

wcswcs() 関数は、見つけたストリングへのポインターを戻すか、ストリングが見つからない場合は、NULL を戻します。string2 がゼロ長のストリングを指す場合には、 wcswcs()string1 を戻します。

この例では、buffer1 でワイド文字ストリング pr が最初に現れる位置を検索します。
#include <stdio.h>
#include <wchar.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 );
}
 
/****************  Output should be similar to:  ******************
 
The first occurrence of pr in 'computer program' is 'program'
*/