A pointer to a wide-character string, where each element is of type `wchar_t`. Used for representing text in wide-character encoding to support extended character sets.
A pointer to a wide-character string, where each element is of type `wchar_t`. Used for representing text in wide-character encoding to support extended character sets.
1st Parameter
Pointer to the destination buffer where the wide-character string will be copied. The buffer must be large enough to hold at least `n` wide characters.
2nd Parameter Type : const wchar_t *
A pointer to a read-only wide-character string, where each character is of type `wchar_t`. Used for representing text in wide-character encoding to support extended character sets, such as Unicode. The string is null-terminated, with the terminator being a `wchar_t` with value 0.
2nd Parameter
Pointer to the source null-terminated wide-character string to be copied.
3rd Parameter Type : size_t
Platform-specific unsigned type for array indices and memory sizes.
3rd Parameter
The maximum number of wide characters to copy from `src` to `dest`.
Read more about parameters of wcsncpy in parameters section
The wcsncpyfunction in C language Copies a specified number of characters from one wide character string to another, ensuring that the destination string will not be overrun.
wcsncpy copies at most n wide characters from the wide string pointed to by src to the wide string pointed to by dest. If the length of src is less than n, the remainder of dest will be padded with null wide characters. If the length of src is greater than or equal to n, dest may not be null-terminated.
The wcsncpyfunction takes 3
parameters:
•
wchar_t * `dest`: Pointer to the destination buffer where the wide-character string will be copied. The buffer must be large enough to hold at least `n` wide characters.
•
const wchar_t * `src`: Pointer to the source null-terminated wide-character string to be copied.
•
size_t `n`: The maximum number of wide characters to copy from `src` to `dest`.
Copies up to `n` wide characters from the wide-character string `src` to the buffer `dest`. If the length of `src` is less than `n`, the remainder of `dest` is filled with null wide characters. The destination string is not null-terminated if the length of `src` is `n` or more. Returns a pointer to `dest`.
The wcsncpy function return value :
Returns a pointer to the destination string dest
Output
This example demonstrates the basic usage of wcsncpy to copy a portion of a wide string.