size_t wcrtomb(char* cpMBChar, wchar_t wWideChar, mbstate_t* qpMBState);
#include <cwchar>
#include <cstdlib>
#include <cstdio>
int main()
{
const wchar_t kwaWideString[] = L"XoaX.net";
char* cpConverted = new char[MB_CUR_MAX];
// Convert the first character of the wide string
size_t uiByteReq = wcrtomb(cpConverted, kwaWideString[0], NULL);
wprintf(L"%d bytes required.\n", uiByteReq);
wprintf(L"Original: %wc\n", kwaWideString[0]);
printf("Converted: %c\n", cpConverted[0]);
delete [] cpConverted;
// Keep the window open until "Enter" is pressed
getwchar();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.