Pointer to the buffer where the multibyte character will be stored. If `s` is `NULL`, the function resets the conversion state.
2nd Parameter Type : wchar_t
A data type used to represent wide characters, typically supporting larger character sets such as Unicode. Its size is platform-dependent but is often 2 or 4 bytes.
2nd Parameter
The wide character to be converted to a multibyte character.
Read more about parameters of wctomb in parameters section
The wctombfunction in C language Converts a wide character to its multibyte representation.
wctomb converts a wide character to its multibyte character representation. It stores the multibyte character representation of wchar in the array pointed to by s (if s is not NULL). The function affects the mbstate_t object maintained internally by the function.
The wctombfunction takes 2
parameters:
•
char * `s`: Pointer to the buffer where the multibyte character will be stored. If `s` is `NULL`, the function resets the conversion state.
•
wchar_t `wc`: The wide character to be converted to a multibyte character.
Converts the wide character `wc` to its multibyte representation and stores it in the buffer pointed to by `s`. Returns the number of bytes written to `s`, or `-1` if the wide character cannot be converted. If `s` is `NULL`, the function resets its internal state and returns a non-negative value if the encoding is state-dependent.
The wctomb function return value :
Returns the number of bytes that constitute the multibyte character corresponding to wchar
If s is NULL, the function returns a nonzero value if multibyte character encodings are state-dependent, and zero otherwise
If wchar is an invalid wide character, -1 is returned
Output
This example demonstrates the basic usage of wctomb to convert a wide character to its multibyte representation.