wcscpy() — Copy Wide-Character Strings
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
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
- strcpy() — Copy Strings
- 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
- <wchar.h>