wcscpy() — ワイド文字ストリングのコピー

形式

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

言語レベル

XPG4

スレッド・セーフ

はい

ワイド文字関数

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

説明

wcscpy() 関数は、 string2 (末尾の wchar_t ヌル文字を含む) の内容を string1にコピーします。

wcscpy() 関数は、ヌル終了 wchar_t ストリングを操作します。この関数のストリング引数には、ストリングの終わりを示す wchar_t ヌル文字が含まれている必要があります。 ヌル文字を含む必要があるのは string2 のみです。 境界検査は実行されません。

戻り値

wcscpy() 関数は、 string1へのポインターを戻します。

この例では、source の内容を destination にコピーします。
#include <stdio.h>
#include <wchar.h>
 
#define SIZE    40
 
int main(void)
{
  wchar_t source[ SIZE ] = L"This is the source string";
  wchar_t destination[ SIZE ] = L"And this is the destination string";
  wchar_t * return_string;
 
  printf( "destination is originally = \"%ls\"\n", destination );
  return_string = wcscpy( destination, source );
  printf( "After wcscpy, destination becomes \"%ls\"\n", destination );
}
 
/****************  Output should be similar to:  ******************
 
destination is originally = "And this is the destination string"
After wcscpy, destination becomes "This is the source string"
*/

関連情報