In C, wmemcpy() copies a non-overlapping wide-character block. It belongs to the wide-character tools declared in <wchar.h>.
Use wchar_t for wide characters and prefix wide literals with L, as in L"Hello". The examples below use simple C Programming Tutorial patterns and print wide strings with %ls.
Syntax
The following concrete call shows the argument shape before the formal declaration.
C
wmemcpy(dest, src, 5);
Call
What it does
wmemcpy(dest, src, 5)
Copies a non-overlapping wide-character block in a typical call.
Include <wchar.h>. Add only the supporting headers actually used by your program.
Prepare a practical variation. The data is arranged specifically to add termination when needed.
Process a counted block.wmemcpy(dest, src, 5) uses a count of wchar_t elements rather than bytes.
Notice the safety rule. The example keeps the count, destination capacity, stream state, and terminator requirements visible.
Interpret the output.Wide confirms the behavior demonstrated by this example.
Frequently Asked Questions
wmemcpy() copies a non-overlapping wide-character block. It is part of the standard wide-character library.
Its parameters are dest, src, count. dest: Writable destination with enough room for the requested result. src: Source pointer; conversion functions update it as input is consumed. count: Maximum number of wchar_t elements to inspect, copy, append, or transform.
Destination pointer means the same destination address passed to the function.
Include <wchar.h> for wmemcpy(). Include only the supporting headers used by your program, such as <stdio.h> for FILE or <stdarg.h> for va_list.
The count is measured in wchar_t elements, not bytes. Counted memory functions do not automatically append L'\0'.