wcstombs() function in C++ STL Last Updated : 06 Jun, 2022 Comments Improve Suggest changes Like Article Like Report 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++. Syntax wcstombs(d, s, n) Parameters: 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. Return Value: 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 occurred then, -1 is returned. Program 1: CPP // Program to illustrate // wcstombs function in C++ #include <cstdlib> #include <iostream> using namespace std; int main() { wchar_t s[] = L"GeeksforGeeks"; char d[100]; int n; n = wcstombs(d, s, 100); cout << "Number of wide character converted = " << n << endl; cout << "Multibyte Character String = " << d << endl; return 0; } Output:Number of wide character converted = 13 Multibyte Character String = GeeksforGeeks Program 2: CPP // Program to illustrate // wcstombs function in C++ #include <cstdlib> #include <iostream> using namespace std; int main() { wchar_t s[] = L"10@Hello World!"; char d[100]; int n; n = wcstombs(d, s, 100); cout << "Number of wide character converted = " << n << endl; cout << "Multibyte Character String = " << d << endl; return 0; } Output:Number of wide character converted = 15 Multibyte Character String = 10@Hello World! Comment I IshwarGupta Follow 0 Improve I IshwarGupta Follow 0 Improve Article Tags : Misc C++ STL CPP-Functions Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read Like