wcsncat() - ワイド文字ストリングへの追加

標準

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

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

両方  

形式

#include <wchar.h>

wchar_t *wcsncat(wchar_t * __restrict__string1, 
                 const wchar_t * __restrict__string2, size_t count);

機能説明

string2 から string1 の終わり まで最大 count ワイド文字を追加し、NULL ワイド文字を結果に追加します。wcsncat() 関数は、NULL 文字で終了するワイド文字ストリングを操作します。この関数に対するストリング引数には、ストリングの終わりにマークを 付ける NULL ワイド文字が入っていなければなりません。

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

戻り値

wcsncat() は、string1 を戻します。

CELEBW13
⁄* CELEBW13                                      

   This example demonstrates the difference between &wcscat. and                
   &wcsncat..                                                                   
   &wcscat. appends the entire second string to the first                       
   whereas &wcsncat. appends only the specified number of                       
   characters in the second string to the first.                                
                                                                                
 *⁄                                                                             
#include <stdio.h>                                                              
#include <wchar.h>                                                              
#include <string.h>                                                             
                                                                                
#define SIZE 40                                                                 
                                                                                
int main(void)                                                                  
{                                                                               
  wchar_t buffer1[SIZE] = L"computer";                                          
  wchar_t * ptr;                                                                
                                                                                
  ⁄* Call wcscat with buffer1 and " program" *⁄                                 
                                                                                
  ptr = wcscat( buffer1, L" program" );                                         
  printf( "wcscat : buffer1 = ¥"%ls¥"¥n", buffer1 );
                                                                                
  ⁄* Reset buffer1 to contain just the string "computer" again *⁄               
                                                                                
  memset( buffer1, L'¥0', sizeof( buffer1 ));
  ptr = wcscpy( buffer1, L"computer" );                                         
                                                                                
  ⁄* Call wcsncat with buffer1 and " program" *⁄                                
  ptr = wcsncat( buffer1, L" program", 3 );                                     
  printf( "wcsncat: buffer1 = ¥"%ls¥"¥n", buffer1 );
}                                                                               
出力:
wcscat : buffer1 = "computer program"
wcsncat: buffer1 = "computer pr"

関連情報