Scroll Down to See All
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrptimestrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1yn



Function Details : vswprintf

intvswprintf(wchar_t * ws,size_t n,const wchar_t * format,va_list args) ;

Return Type : int

Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
Read about return values of vswprintf 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 `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 may include format specifiers like `%ls`, `%d`, etc.

4th Parameter Type : va_list

A data type used to hold information about variable arguments passed to a variadic function. It is initialized with `va_start`, used with `va_arg`, and cleaned up with `va_end`.

4th Parameter

The variable argument list containing the values to be formatted and written. It must be initialized with `va_start`.

Read more about parameters of vswprintf in parameters section
The vswprintffunction in C language Writes formatted wide character output to a string with size limitation using a va_list.
vswprintf is similar to swprintf, but instead of taking a variable number of arguments, it takes a va_list that has been initialized by va_start. This function writes at most size - 1 wide characters to the output string, ensuring it's always null-terminated. It's used for formatting wide character strings with the added safety of buffer overflow prevention.
The vswprintffunction 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 `ws`.
  • const wchar_t * `format`: Pointer to a null-terminated wide-character string specifying the format of the output. It may include format specifiers like `%ls`, `%d`, etc.
  • va_list `args`: The variable argument list containing the values to be formatted and written. It must be initialized with `va_start`.
Writes a formatted wide-character string to the buffer `ws` with a limit of `n` wide characters, including the null terminator. If the formatted string exceeds the buffer size, it is truncated. Returns the number of wide characters (excluding the null terminator) that would have been written if the buffer were large enough, or a negative value if an encoding error occurs.
The vswprintf function return value :
  • Returns the number of wide characters written, not including the terminating null wide character
  • If an encoding error occurs or if the number of wide characters to be written would exceed size, a negative number is returned

Output

This example demonstrates using vswprintf in a custom function to format a wide character string with various types of arguments.