Synopsis
size_t wcrtomb(char *s,
               wchar_t wc,
               mbstate_t *ps);

If s is a null pointer, wcrtomb function is equivalent to the call wcrtomb(buf, L'\0', ps) where buf is an internal buffer.

If s is not a null pointer, wcrtomb determines the number of bytes needed to represent the multibyte character that corresponds to the wide character given by wc, and stores the multibyte character representation in the array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If wc is a null wide character, a null byte is stored; the resulting state described is the initial conversion state.

wcrtomb returns the number of bytes stored in the array object. When wc is not a valid wide character, an encoding error occurs: wcrtomb stores the value of the macro EILSEQ in errno and returns (size_t)(-1); the conversion state is unspecified.