Format
#include <wchar.h>
wchar_t *wcscpy(wchar_t *string1, const wchar_t *string2);
Language Level: XPG4
Threadsafe: Yes.
Wide Character Function: See Wide Characters for more information.
Description
The wcscpy() function copies the contents of string2 (including the ending wchar_t null character) into string1.
The wcscpy() function operates on null-ended wchar_t strings; string arguments to this function should contain a wchar_t null character marking the end of the string. Only string2 needs to contain a null character. Boundary checking is not performed.
Return Value
The wcscpy() function returns a pointer to string1.
Example that uses wcscpy()
This example copies the contents of source to destination.
#include <stdio.h>
#include <wchar.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", destination );
}
/**************** Output should be similar to: ******************
destination is originally = "And this is the destination string"
After wcscpy, destination becomes "This is the source string"
*/
Related Information