This vswprintf() function writes the wide string to the wide string buffer. A maximum of (len-1) wide characters are written to buffer which is followed by a null wide character.
int vswprintf( wchar_t* ws, size_t len, const wchar_t* format, va_list arg )
Parameters: The function accepts four mandatory parameters which are described below:
- ws: specifies the pointer to a given wide string buffer which will store the result
- len: specifies the maximum length of wide characters written back to the buffer including the terminating null character
- format: specifies the pointer to a null terminated wide string
- arg: specifies the value identifying a variable arguments list
Note: All format specifiers have the same meaning as in printf therefore, %lc shall be used to write a wide character ( and not %c ), as well as %ls shall be used for wide strings ( and not %s ).
Return value: The function returns two value as below:
- On success, the vswprintf() function returns number of wide characters written excluding the terminating null wide character.
- A negative number is returned on failure, including when the resulting string to be written to ws would be longer than n characters.
Below programs illustrate the above function:
Program 1 :
Some Latin letters : % & ' ( )
Program 2 :
GFG is : Geek for g
Note: If the resulting string would be longer than n-1 wide characters, the remaining characters are discarded and not stored.
- Function Overloading vs Function Overriding in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- exp() function C++
- log() function in C++
- fma() function in C++
- div() function in C++
- arc function in C
- feupdateenv() function in C++
- raise() function in C++
- iswlower() function in C/C++
- fread() function in C++
- tellg() function in C++ with example
- wcstombs() function in C++ STL
- Address of a function in C or C++
- strlwr() function in C
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.