wcscpy() — Copy wide-character string
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C Amendment |
both |
Format
#include <wchar.h>
wchar_t *wcscpy(wchar_t * __restrict__string1, const wchar_t * __restrict__string2);
General description
Copies the contents of string2 (including the ending wide NULL character) into string1. The wcscpy() function operates on NULL-terminated wide-character strings. The string arguments to this function must contain a wide NULL character marking the end of the string. Bounds checking is not performed.
The behavior of this wide-character function is affected by the LC_CTYPE category of the current locale. If you change the category, undefined results can occur.
Returned value
wcscpy() returns the value of string1.
Example
CELEBW08
/* CELEBW08
This example copies the contents of source to destination using
wcscpy().
*/
#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:
destination is originally = "And this is the destination string"
After wcscpy, destination becomes "This is the source string"
Related information
- wchar.h
- wcstr.h
- strcpy() — Copy string
- wcscat() — Append to wide-character string
- wcschr() — Search for wide-character substring
- wcscmp() — Compare wide-character strings
- wcscspn() — Find offset of first wide-character match
- wcslen() — Calculate length of wide-character string
- wcsncpy() — Copy wide-character string