##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# wcrtomb

From cppreference.com
< c‎ | string‎ | multibyte

Defined in header `<wchar.h>` |  |
size_t wcrtomb( char* s, wchar_t wc, mbstate_t* ps); |  |

Converts a wide character to its narrow multibyte representation.

If `s` is not a null pointer, the function determines the number of bytes necessary to store the multibyte character representation of `wc` (including any shift sequences), and stores the multibyte character representation in the character array whose first element is pointed to by `s`. At most MB_CUR_MAX bytes can be written by this function.

If `s` is a null pointer, the call is equivalent to wcrtomb(buf, L'\0', ps) for some internal buffer `buf`.

If wc is the null wide character L'\0', a null byte is stored, preceded by any shift sequence necessary to restore the initial shift state and the conversion state parameter *ps is updated to represent the initial shift state.

### [edit] Parameters

s | - | pointer to narrow character array where the multibyte character will be stored
wc | - | the wide character to convert
ps | - | pointer to the conversion state object used when interpreting the multibyte string

### [edit] Return value

On success, returns the number of bytes (including any shift sequences) written to the character array whose first element is pointed to by `s`.

On failure (if wc is not a valid wide character), returns (size_t)-1, stores EILSEQ in errno, and leaves *ps in unspecified state.

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

wctomb | converts a wide character to its multibyte representation (function) [edit]
mbrtowc | converts the next multibyte character to wide character, given state (function) [edit]
C++ documentation for wcrtomb

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/string/multibyte/wcrtomb&oldid=56806"
Category:

- Todo no example