Scroll Down to See All
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1yn



Function Details : wcstombs

size_twcstombs(char * dest,const wchar_t * src,size_t n) ;

Return Type : size_t

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

1st Parameter Type : char *

String pointer (array of characters)

1st Parameter

Pointer to the destination buffer where the converted multibyte sequence will be stored.

2nd Parameter Type : const wchar_t *

A pointer to a read-only wide-character string, where each character is of type `wchar_t`. Used for representing text in wide-character encoding to support extended character sets, such as Unicode. The string is null-terminated, with the terminator being a `wchar_t` with value 0.

2nd Parameter

Pointer to the null-terminated wide-character string to be converted.

3rd Parameter Type : size_t

Platform-specific unsigned type for array indices and memory sizes.

3rd Parameter

The maximum number of bytes to write to `dest`.

Read more about parameters of wcstombs in parameters section
The wcstombsfunction in C language Converts a wide character string to a multibyte character string.
wcstombs converts a sequence of wide characters from the array pointed to by wcs to a sequence of corresponding multibyte characters that begins in the initial shift state, and stores them in the array pointed to by s. The conversion continues up to and including the terminating null wide character.
The wcstombsfunction takes 3 parameters:
  • char * `dest`: Pointer to the destination buffer where the converted multibyte sequence will be stored.
  • const wchar_t * `src`: Pointer to the null-terminated wide-character string to be converted.
  • size_t `n`: The maximum number of bytes to write to `dest`.
Converts the wide-character string `src` to a multibyte string and stores it in the buffer `dest`. Writes at most `n` bytes, including the null terminator. Returns the number of bytes written (excluding the null terminator) or `(size_t)-1` if a conversion error occurs.
The wcstombs function return value :
  • Returns the number of bytes written to the destination string
  • If an invalid multibyte character is encountered, (size_t)(-1) is returned

Output

This example demonstrates the basic usage of wcstombs to convert a wide character string to a multibyte string.