C Standard Libraries C++

btowc()

Declaration

wint_t btowc(int iByte);

Description

This function returns the wide two-byte character (wchar_t) converted from the single byte "iByte" character (char). If the argument is not a valid multibyte sequence of length 1, then the function returns WEOF. The output is affected by the current LC_TYPE locale.

Example

#include <iostream>
#include <cwchar>

int main() {
    using namespace std;

    char caName[] = "XoaX.net";
    // Convert and output each char as a wide char.
    for (int iIndex = 0; iIndex < 8; ++iIndex) {
        wcout << (wchar_t)btowc(caName[iIndex]) << endl;
    }
    return 0;
}

Output

btowc() Output
 

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