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 characters to multibyte strings

&pagelevel(4)&pagelevel

Definition  

#include <stdlib.h>

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

wcstombs converts a sequence of wide characters (type wchar_t) in pwcs to the corresponding multibyte characters and stores these in string s. n indicates the maximum number of bytes to be stored in s.
n specifies the maximum number of bytes to be stored in s.

The assignment is terminated if

  • the wide character 0 occurs in pwcs,

  • n bytes have already been assigned or

  • a wide character cannot be represented in one byte.

Return val.

Number of assigned bytes



if successful


(size_t)-1

if a wide character cannot be converted to a multibyte character.              

Notes

If a wide character in pwcs cannot be converted to a multibyte character, the wide characters already converted are stored in s.

The behavior is undefined if memory areas overlap.

No characters consisting of multiple bytes are implemented in this version. Multibyte and wide characters always have a length of 1 byte. wcstombs converts each wide character in pwcs to a one-byte multibyte character and saves it in string s.

See also

mblen, mbtowc, mbstowcs, wctomb