Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

wcstombs - convert wide character string to character string

&pagelevel(4)&pagelevel

Syntax

#include <stdlib.h>

size_t wcstombs(char *s, const wchar_t *pwcs, size_t n); 

Description

wcstombs() converts a sequence of wchar_t values located in pwcs to the appropriate
multi-byte characters and stores them in string s.
n specifies the maximum number of bytes to be stored in s.

No characters consisting of multiple bytes are implemented in this version. Multi-byte
characters always have a length of 1 byte, and wchar_t values are always of type long.
wcstombs() assigns each wchar_t value (of type long) in pwcs to an area of 1-byte length
in string s.

The assignment terminates:

  • on encountering the wchar_t value 0 in pwcs,

  • when n bytes have been assigned or

  • on encountering a wchar_t value that cannot be represented in 1 byte.

Return val.

Number of assigned bytes


upon successful conversion.

(size_t)-1

if a wchar_t value cannot be converted to a multi-byte character.

Notes

If a wchar_t value in pwcs cannot be converted to a multi-byte character, the wchar_t
values already converted will be stored in s.

The behavior is undefined if memory areas overlap.

Restriction
This version of the C runtime system only supports 1-byte characters as wide character
codes. They are of type wchar_t (see stddef.h). (End)

See also

mblen(), mbtowc(), mbstowcs(), wctomb(), stdlib.h.