wcstombs() is a builtin function in C++ STL which converts a wide character string to its equivalent multibyte sequence. It is defined within the cstdlib header file of C++.
wcstombs(d, s, n)
- d: It is the parameter which specifies the pointer to a character array at least n bytes long.
- s: It is the parameter which specifies wide-character string to be converted.
- n: It is the parameter which specifies maximum number of wide characters to be converted.
- If the conversion is successful then the function returns the number of bytes (not characters) converted and written to the string, excluding the terminating null character(‘\0’).
- If any error is occured then, -1 is returned.
Number of wide character converted = 13 Multibyte Character String = GeeksforGeeks
Number of wide character converted = 15 Multibyte Character String = 10@Hello World!
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.
- Difference between user defined function and library function in C/C++
- How to call some function before main() function in C++?
- Function Overloading vs Function Overriding in C++
- How to call function within function in C or C++
- What happens when a virtual function is called inside a non-virtual function in C++
- Difference between Virtual function and Pure virtual function in C++
- div() function in C++
- fma() function in C++
- exp() function C++
- log() function in C++
- wcsncpy() function in C++ with example
- wcstok() function in C++ with example
- wcsstr() function in C++ with example
- imag() function in C++
- real() function in C++
- regex_iterator() function in C++ STL
- map rbegin() function in C++ STL
- map key_comp() function in C++ STL
- max() function for valarray in C++
- valarray cos() function in C++
Improved By : ManasChhabra2