Syntax
#include <wchar.h> wchar_t *wcsncat(wchar_t *string1, const wchar_t *string2, size_t count);Description
wcsncat appends up to count wide characters from string2 to the end of string1, and appends a wchar_t null character to the result.
wcsncat operates on null-terminated wide-character strings; string arguments to this function should contain a wchar_t null character marking the end of the string.
wcsncat returns string1.
This example demonstrates the difference between wcscat and wcsncat. wcscat appends the entire second string to the first; wcsncat appends only the specified number of characters in the second string to the first.
#include <stdio.h> #include <wchar.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); return 0; /**************************************************************************** The output should be: wcscat : buffer1 = "computer program" wcsncat: buffer1 = "computer pr" ****************************************************************************/ }Related Information