![]() |
![]() |
![]() |
C++ Reference: wcstombs()
wcstombs()
Declaration
size_t wcstombs(char* cpMultibyteString,
const wchar_t* kwpString,
size_t qMaxCount);
Description
This function converts a wide character string to to a multibyte string.
Example
#include <cstdlib>
#include <cstdio>
int main() {
wchar_t waWideChar[] = L"XoaX.net";
char* cpMultibyteString = new char[9*MB_CUR_MAX];
// Convert to a multibyte string
int iConvertLength = wcstombs(cpMultibyteString, waWideChar, 9*MB_CUR_MAX);
// Null terminate the chars
cpMultibyteString[iConvertLength] = 0;
printf("Conversion Length = %d\n", iConvertLength);
printf("Conversion = %s\n", cpMultibyteString);
delete [] cpMultibyteString;
// Keep the window open until "Enter" is pressed
getchar();
return 0;
}
Output:
![]() |
![]() |
![]() |
| Home | | | Reference | | | Play Games! | | | Blog | | | Forum | | | Site Map | | | Contact Us |





