C <wchar.h> - wcscpy() Function
The C <wchar.h> wcscpy() function is used to copy the wide string pointed to by source, including the null character, to the wide character array whose first element is pointed to by destination.
The behavior is undefined if the destination is not large enough for the content of source (including the null character), or if the strings overlap.
Syntax
wchar_t* wcscpy (wchar_t* destination, const wchar_t* source);
Parameters
destination |
Specify pointer to the wide character array where the content is to be copied. |
source |
Specify pointer to the null-terminated wide string to copy from. |
Return Value
Returns destination.
Example:
The example below shows the usage of wcscpy() function.
#include <stdio.h> #include <wchar.h> int main (){ wchar_t str1[256] = L"xyz"; wchar_t str2[256]; wchar_t str3[256] = L"Hello World!"; //replacing the content of str1 //and str2 with str3 wcscpy(str1, str3); wcscpy(str2, str3); printf("str1 is: %ls\n", str1); printf("str2 is: %ls\n", str2); return 0; }
The output of the above code will be:
str1 is: Hello World! str2 is: Hello World!
❮ C <wchar.h> Library