Javatpoint Logo
Javatpoint Logo

wcrtomb() function in C/C++

The wcrtomb() function in C/C++ transforms a wide character to its narrow multibyte representations. The wide-character wc is converted to its multibyte counterparts and saved in the array referenced by s. The method returns the length in bytes of the corresponding multibyte sequence pointed to s.


It has the following Syntax:

Parameters: The function requires three necessary arguments, which are listed below:

  • st: It provides the reference to an array large enough to store a multibyte sequence.
  • wcl: It indicates the wide characters to convert.
  • pss: It define the conversion state used while reading the multibyte text.

Return values: The method returns the following values:

  • If it succeeds, it returns the number of bytes transferred to the character array whose initial element is referenced to by st.
  • If not, it returns -1 and changes errno to EILSEQ.

The wcrtomb_s function transforms a wide character, starting in the given conversion state stored in mbstate, from the numerical value contained in wcl to the location represented by mbchar. The pReturnValue value will represent the total amount of bytes converted, but not more than MB_CUR_MAX bytes, or -1 if an error occurs.

If mbstate is empty, the internal mbstate_t conversion condition is utilized. If a single character in wcl does not have a matching multibyte character, the value of pReturnValue is -1, and the method returns the EILSEQ errno result.



Size of zU is 1 bytes
Invalid wide character
Invalid wide character
Invalid wide character

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA