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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- What happens when a virtual function is called inside a non-virtual function in C++
- Function Overloading vs Function Overriding in C++
- Difference between Virtual function and Pure virtual function in C++
- How to call some function before main() function in C++?
- How to call function within function in C or C++
- Difference between user defined function and library function in C/C++
- Difference between virtual function and inline function in C++
- Can we call an undeclared function in C++?
- Can we use function on left side of an expression in C and C++?
- Declare a C/C++ function returning pointer to array of integer pointers
- Function overloading and return type
- Function Pointer in C
- Default arguments and virtual function
- Function overloading and const keyword
- How to measure time taken by a function in C?
- Comparator function of qsort() in C
- Can we access private data members of a class without using a member or a friend function?
- Function Overloading and float in C++
- Extra brackets with function names in C/C++
- Function Interposition in C with an example of user defined malloc()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.