Scroll Down to See All
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1yn



Function Details : wcrtomb

size_twcrtomb(char * s,wchar_t wc,mbstate_t * ps) ;

Return Type : size_t

Platform-specific unsigned type for array indices and memory sizes.
Read about return values of wcrtomb function .

1st Parameter Type : char *

String pointer (array of characters)

1st Parameter

Pointer to the output buffer where the multibyte sequence will be written. If `s` is `NULL`, the function resets the conversion state to the initial state and does not write any output.

2nd Parameter Type : wchar_t

A data type used to represent wide characters, typically supporting larger character sets such as Unicode. Its size is platform-dependent but is often 2 or 4 bytes.

2nd Parameter

The wide character to be converted into a multibyte sequence.

3rd Parameter Type : mbstate_t *

A pointer to an `mbstate_t` object that represents the current shift state for multibyte to wide character conversions. This pointer allows modification of the state during the conversion process.

3rd Parameter

Pointer to a conversion state object. If `ps` is `NULL`, the function uses its own internal state.

Read more about parameters of wcrtomb in parameters section
The wcrtombfunction in C language Converts a wide character to a multibyte sequence.
wcrtomb converts a wide character to its multibyte representation. It stores the multibyte character representation of wc in the array pointed to by s (if s is not NULL). The conversion is affected by the LC_CTYPE category of the current locale and the conversion state pointed to by ps.
The wcrtombfunction takes 3 parameters:
  • char * `s`: Pointer to the output buffer where the multibyte sequence will be written. If `s` is `NULL`, the function resets the conversion state to the initial state and does not write any output.
  • wchar_t `wc`: The wide character to be converted into a multibyte sequence.
  • mbstate_t * `ps`: Pointer to a conversion state object. If `ps` is `NULL`, the function uses its own internal state.
Converts the wide character `wc` into a corresponding multibyte sequence and writes it to the buffer `s`. The function uses the conversion state pointed to by `ps` to perform the operation. Returns the number of bytes written to `s` or `(size_t)(-1)` if an error occurs. If `s` is `NULL`, the conversion state is reset to its initial state.
The wcrtomb function return value :
  • Returns the number of bytes stored in the array pointed to by s if s is not NULL
  • If wc can be represented as a multibyte sequence (according to the current locale), the value returned is the number of bytes that make up the converted multibyte character
  • If wc cannot be represented as a multibyte sequence, it returns (size_t)(-1) and sets errno to EILSEQ

Output

This example demonstrates the basic usage of wcrtomb to convert a wide character to its multibyte representation.