函式
<cwchar>

wcsncat

wchar_t* wcsncat (wchar_t* destination, const wchar_t* source, size_t num);
從寬字串追加字元
source 的前 num 個寬字元,加上一個終止的空寬字元,追加到 destination

如果 source 中的 C 寬字串長度小於 num,則只複製直到終止的空寬字元的內容。

這是 strncat (<cstring>) 的寬字元等價函式。

引數

destination
指向目標陣列的指標,該陣列應包含一個 C 寬字串,並且足夠大以容納連線後的結果字串,包括額外的空寬字元
source
要追加的 C 寬字串。
num
要追加的最大字元數。
size_t 是一個無符號整數型別。

返回值

返回 destination

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
/* wcsncat example */
#include <wchar.h>

int main ()
{
  wchar_t wcs1[20];
  wchar_t wcs2[20];
  wcscpy ( wcs1, L"To be " );
  wcscpy ( wcs2, L"or not to be" );
  wcsncat ( wcs1, wcs2, 6 );
  wprintf ( L"%ls\n", wcs1);
  return 0;
}

輸出

To be or not


另見