size_t mbstowcs(wchar_t* wpString,
const char* kcpMultibyteString,
size_t qCount);#include <iostream>
#include <cstdlib>
int main() {
using namespace std;
wchar_t waWideChar[] = L"XoaX.net";
char* cpMultibyteString = new char[9*MB_CUR_MAX];
int iConvertLength = (int)wcstombs(cpMultibyteString, waWideChar, 9*MB_CUR_MAX);
// Convert to a multibyte string
cpMultibyteString[iConvertLength] = 0;
cout << "Conversion Length = " << iConvertLength << endl;
cout << "Conversion to Multibyte= " << cpMultibyteString << endl;
// Convert back to a wide string
wchar_t waConvWideChar[30];
int iConvertedBack = (int)mbstowcs(waConvWideChar, cpMultibyteString, iConvertLength);
cout << "Conversion Back Length = " << iConvertedBack << endl;
cout << "Value of First Wide Back = " << waConvWideChar[0] << endl;
}
© 20072025 XoaX.net LLC. All rights reserved.