Format
#include <wcstr.h> wchar_t *wcscpy(wchar_t *string1, const wchar_t *string2);
Language Level: XPG4
wcscpy copies the contents of string2 (including the
ending wchar_t null character) into string1.
wcscpy operates on null-terminated wchar_t strings; string arguments to this function should contain a wchar_t null character marking the end of the string.
Boundary checking is not performed.
Return Value
wcscpy returns a pointer to string1.
Example
This example copies the contents of source to
destination.
#include <stdio.h> #include <wcstr.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", return_string); return 0;
/**********************************************************************
The output should be:
destination is originally = "And this is the destination string"
After wcscpy, destination becomes "This is the source string"
**********************************************************************/
}
![]()
strcpy -- Copy Strings
strdup -- Duplicate String
strncpy -- Copy Strings
wcscat -- Concatenate Wide-Character
Strings
wcschr -- Search for Wide Character
wcscmp -- Compare Wide-Character
Strings
wcscspn -- Find Offset of First
Wide-Character Match
wcslen -- Calculate Length of
Wide-Character String
wcsncpy -- Copy Wide-Character Strings
<wcstr.h>