Pointer to a pointer to the source wide-character string to be converted.
3rd Parameter Type : size_t
Platform-specific unsigned type for array indices and memory sizes.
3rd Parameter
Maximum number of bytes to write to `dest`.
4th Parameter Type : mbstate_t *
A pointer to an `mbstate_t` object that represents the current shift state for multibyte to wide character conversions. This pointer allows modification of the state during the conversion process.
4th Parameter
Pointer to a conversion state object used for multibyte conversions.
Read more about parameters of wcsrtombs in parameters section
The wcsrtombsfunction in C language Converts a sequence of wide characters from a wide character string to a multibyte string, considering the current locale.
wcsrtombs converts a sequence of wide characters from the array indirectly pointed to by src into a sequence of corresponding multibyte characters that begins in the initial shift state described by ps. If dst is not a null pointer, the converted characters are then stored into the array pointed to by dst. Conversion continues up to and including a terminating null wide character, which is also converted.
The wcsrtombsfunction takes 4
parameters:
•
char * `dest`: Pointer to the destination buffer where the multibyte sequence will be stored.
•
const wchar_t ** `src`: Pointer to a pointer to the source wide-character string to be converted.
•
size_t `len`: Maximum number of bytes to write to `dest`.
•
mbstate_t * `ps`: Pointer to a conversion state object used for multibyte conversions.
Converts a wide-character string to a multibyte string, using the state object `ps`. Returns the number of bytes written to `dest` or `(size_t)-1` if an error occurs.
The wcsrtombs function return value :
If dst is not NULL, returns the number of bytes in the resulting multibyte character sequence, not including the terminating null byte
If dst is NULL, returns the required size of the destination string
If an invalid wide character is encountered, (size_t)(-1) is returned and errno is set to EILSEQ
Output
This example demonstrates the basic usage of wcsrtombs to convert a wide character string to a multibyte string.