C Standard Libraries C++

wctob()

Declaration

int wctob(wint_t wChar);

Description

This function converts the wide-character "wChar" to a multibyte character and returns its value. If the character could not be converted, the function returns -1.

Example

#include <cwchar>

int main()
{
    wchar_t waString[] = L"XoaX.net";

    // Convert each character to a multibyte character
    for (int i = 0; i < 8; ++i) {
        int iChar = wctob(waString[i]);
        wprintf(L"\"%wc\" converted to \"%c\"\n",
            waString[i], (char)iChar);
    }

    // Keep the window open until "Enter" is pressed
    getwchar();
    return 0;
}

Output

wctob() Output
 

© 2007–2022 XoaX.net LLC. All rights reserved.