Scroll Down to See All
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1yn



Function Details : swprintf

intswprintf(wchar_t * ws,size_t n,const wchar_t * format,... args) ;

Return Type : int

Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
Read about return values of swprintf function .

1st Parameter Type : wchar_t *

A pointer to a wide-character string, where each element is of type `wchar_t`. Used for representing text in wide-character encoding to support extended character sets.

1st Parameter

Pointer to the wide-character string buffer where the formatted output will be stored. The buffer must be large enough to hold the resulting string, including the null terminator.

2nd Parameter Type : size_t

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

2nd Parameter

The maximum number of wide characters (including the null terminator) to be written to the buffer pointed to by `ws`.

3rd 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.

3rd Parameter

Pointer to a null-terminated wide-character string specifying the format of the output. It can include format specifiers like `%d`, `%ls`, etc.

4th Parameter Type : ...

Represents a variable number of arguments in a function. Used in functions like `printf` or `fprintf` to accept additional parameters beyond those explicitly declared.

4th Parameter

Additional arguments providing the values to format and write to the output string.

Read more about parameters of swprintf in parameters section
The swprintffunction in C language Writes formatted wide character output to a string.
The swprintf function is the wide-character equivalent of sprintf. It writes the formatted wide character output to the wide string pointed to by wcs. The function follows the same formatting rules as sprintf, but operates on wide characters and strings.
The swprintffunction takes 4 parameters:
  • wchar_t * `ws`: Pointer to the wide-character string buffer where the formatted output will be stored. The buffer must be large enough to hold the resulting string, including the null terminator.
  • size_t `n`: The maximum number of wide characters (including the null terminator) to be written to the buffer pointed to by `ws`.
  • const wchar_t * `format`: Pointer to a null-terminated wide-character string specifying the format of the output. It can include format specifiers like `%d`, `%ls`, etc.
  • ... `args`: Additional arguments providing the values to format and write to the output string.
Writes a formatted wide-character string to the buffer `ws` based on the format string `format` and additional arguments. The maximum number of wide characters written (including the null terminator) is limited by `n`. Returns the number of wide characters written (excluding the null terminator), or a negative value if an error occurs.
The swprintf function return value :
  • Returns the number of wide characters written, not including the terminating null wide character
  • If an encoding error occurs, a negative number is returned

Output

This example demonstrates basic usage of swprintf to format a wide string with a name and age.